Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7.4k views
in .NET FTP by
Every time I try to Get a file that is more than zero bytes, .NET throws this exception:

----
An unhandled exception of type 'System.IO.Exception' occured in mscorlib.dll

Additional Information: The process cannot access the file "c:\sourcefiles\3COM\3c90x1.exe" because it is being used by another process.
----

It isn't in use by any other process, it can't be, as it wasn't even in existence before the get call. Here's sample code I'm using:


Dim ftp As FTPClient = Nothing
ftp = New FTPClient("ftp.xxx.com")

ftp.Login("xxx", "xxx")

ftp.ConnectMode = FTPConnectMode.PASV
ftp.TransferType = FTPTransferType.ASCII

ftp.Get("c:\sourcefiles\3COM\3c90x1.exe", "/3COM/3c90x1.exe")

I think it has something to do with the subdirectories, as this works if I stay in the root. "c:\sourcefiles\3COM\" exists as a valid directory, and an empty file from /3COM/ on the ftp server works just file.

What am I doing wrong?

thanks...

Jeremy

9 Answers

0 votes
by (162k points)
Try changing into the 3COM dir on the remote server before get()'ing the file, using cwd().

Every time I try to Get a file that is more than zero bytes, .NET throws this exception:

----
An unhandled exception of type 'System.IO.Exception' occured in mscorlib.dll

Additional Information: The process cannot access the file "c:\sourcefiles\3COM\3c90x1.exe" because it is being used by another process.
----

It isn't in use by any other process, it can't be, as it wasn't even in existence before the get call. Here's sample code I'm using:


Dim ftp As FTPClient = Nothing
ftp = New FTPClient("ftp.xxx.com")

ftp.Login("xxx", "xxx")

ftp.ConnectMode = FTPConnectMode.PASV
ftp.TransferType = FTPTransferType.ASCII

ftp.Get("c:\sourcefiles\3COM\3c90x1.exe", "/3COM/3c90x1.exe")

I think it has something to do with the subdirectories, as this works if I stay in the root. "c:\sourcefiles\3COM" exists as a valid directory, and an empty file from /3COM/ on the ftp server works just file.

What am I doing wrong?

thanks...

Jeremy
0 votes
by
Sorry, I'm using 1.1.3 with vs.net 2003.

Also, I tried the following without success:

ftp.chdir("\3COM\")
ftp.get("c:\sourcefiles\3COM\","3c90x1.exe")

and

ftp.chdir("\3COM\")
ftp.get("c:\sourcefiles\3COM\3c90x1.exe","3c90x1.exe")

it seems to download the file (according to time waiting for the error and the ftp server logs) but then just can't seem to write it correctly.

Thanks again,

Jeremy
0 votes
by
I'll try that next! :)
0 votes
by
I've only got a chdir() for ftpclient. is that what you meant? Well anyway, that didn't work, but thanks for the speedy reply! wow!

finally figured out that bool "ftpfile.isdir" is really "dir". Is that a documentation bug?
0 votes
by
not ASCII, Binary! Sorry I didn't see that. Weird error though. The real error I got to by doing it as a stream, it was something about having a high instead of a low or something like that. It works now.

thanks!
0 votes
by
I am having the same problem. No matter what I use for the local directory, I always get back "System.UnauthorizedAccessException - Access to the path "<any path>" is denied." This error must be a red herring as there should be no reason access should be denied to the local hard drive.

I've tried with a trailing "\" on the path also, but nothing works.

Also, how do you set the local directory, like "lcd" on other versions of ftp?

Brian
0 votes
by
Doh!!

localpath = <folder name>\<file name>

If you use a folder name only, without the local file name, you get the access denied error.

Brian
0 votes
by
Code:

FTPClient ftpData=new FTPClient();
ftpData.RemoteHost="10.128.64.8";
ftpData.ControlPort=21;
ftpData.Connect();
ftpData.Login("test","migoalok");
string localFile = "d:\test.txt";
ftpData.Get(localFile,"test.txt");

The following information is the FTP Server's Log:

[3] Fri 15Apr05 14:01:39 - (000855) Sending file d:\download\test.txt
[3] Fri 15Apr05 14:01:43 - (000855) Error sending file d:\download\test.txt, aborting (7.92 kB/sec - 32768 Bytes, client closed data connection)
0 votes
by (162k points)
You may not have permission to write to the root of D:

Also, i would think

string localFile "d:\\test.txt"

is what you mean

Code:

FTPClient ftpData=new FTPClient();
ftpData.RemoteHost="10.128.64.8";
ftpData.ControlPort=21;
ftpData.Connect();
ftpData.Login("test","migoalok");
string localFile = "d:\test.txt";
ftpData.Get(localFile,"test.txt");

The following information is the FTP Server's Log:

[3] Fri 15Apr05 14:01:39 - (000855) Sending file d:\download\test.txt
[3] Fri 15Apr05 14:01:43 - (000855) Error sending file d:\download\test.txt, aborting (7.92 kB/sec - 32768 Bytes, client closed data connection)

Categories

...