FileExists says file exists even when it does not

Advertisement

Karen Healey
Guest

FileExists says file exists even when it does not

I am using the latest WinSCP, just downloaded today on Windows 7. I copied your VB example

https://winscp.net/eng/docs/library_session_getfiles#example

The line : If mySession.FileExists(remotePath) Then

always returns true, even though the file does not exist. Then, it "gets" an empty file. Session log is attached.

What am I doing wrong?

Thank you,

Karen Healey

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: FileExists says file exists even when it does not

As you can see in the log, your server provides information (possibly fake) for the file /infiles/dhcdheat/export20141103.txt as if it existed.

> 2014-11-03 16:25:43.869 Script: stat -- "/infiles/dhcdheat/export20141103.txt"
. 2014-11-03 16:25:43.869 Listing file "/infiles/dhcdheat/export20141103.txt".
> 2014-11-03 16:25:43.869 Type: SSH_FXP_LSTAT, Size: 45, Number: 263
< 2014-11-03 16:25:43.884 Type: SSH_FXP_ATTRS, Size: 13, Number: 263
. 2014-11-03 16:25:43.884 export20141103.txt;-;0;1899-12-30T05:00:00.000Z;"" [0];"" [0];r-xr-xr-x;0
< 2014-11-03 16:25:43.884 Script: -r-xr-xr-x 0 0 Dec 30 0:00:00 1899 export20141103.txt

If the file does not exist, it's a server-side bug.
Last edited by martin on 2014-11-07; edited 1 time in total

Reply with quote

Guest

Re: FileExists says file exists even when it does not

Oh.. thanks! The file definitely does not exist because I was deliberately testing that scenario. I'm not sure why the server is reporting that it does exist. That is very strange.

I'll find a work around.

Thank you,

Karen Healey

Reply with quote

Guest

Re: FileExists says file exists even when it does not

Why would the server say that a file exists when it doesn't? Is this possibly a response from a non-Windows server?

Thanks,

Karen Healey

Reply with quote

Guest

Re: FileExists says file exists even when it does not

In addition, GetFileInfo is returning invalid information even when the file exists. I wanted to check for a length of 0 but even files that exist have a length of 0 according to GetFileInfo. Clearly, the server is returning invalid information, but the question remains, Why?

Thanks,

Karen Healey

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: FileExists says file exists even when it does not

Anonymous wrote:

In addition, GetFileInfo is returning invalid information even when the file exists. I wanted to check for a length of 0 but even files that exist have a length of 0 according to GetFileInfo. Clearly, the server is returning invalid information, but the question remains, Why?
No idea. What is your server? I didn't checked before removing the log file.

Reply with quote

Advertisement

You can post new topics in this forum