Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12.1k views
in .NET FTP by
I'm using the open source "edtftpnet-1.2.2.dll" in my C# program to download a file from FTP server. The file exists on the server but when the method DownloadFile(_localFolderPath, _remotefileName) is called an exception is thrown indicating that access is denied to tha path specified as the first parameter. Anybody has an idea how this can be fixed?
Thanks,
Gilgamesh

10 Answers

0 votes
by (162k points)
What parameters are you supplying? What's the stack trace?

I'm using the open source "edtftpnet-1.2.2.dll" in my C# program to download a file from FTP server. The file exists on the server but when the method DownloadFile(_localFolderPath, _remotefileName) is called an exception is thrown indicating that access is denied to tha path specified as the first parameter. Anybody has an idea how this can be fixed?
Thanks,
Gilgamesh
0 votes
by
The first parameter is "'C:\\Data_B2G\\UploadFolder\\Interface\\1007\\Order' and the second parameter is "Test.txt".


Here is the error:
- ex {"Access to the path 'C:\\Data_B2G\\UploadFolder\\Interface\\1007\\Order' is denied."} System.Exception {System.UnauthorizedAccessException}

Here is the stack trace:
StackTrace " at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)\r\n at System.IO.FileStream..ctor(String path, FileMode mode)\r\n at EnterpriseDT.Net.Ftp.FTPClient.GetBinary(String localPath, String remoteFile)\r\n at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)\r\n at EnterpriseDT.Net.Ftp.FTPConnection.DownloadFile(String localPath, String remoteFile)\r\n at B2Gnow.Automated.FileSniffer.Sniffer.MoveFolder(FTPConnection ftpConn, String organizationID, String interafceFodler) in C:\\Data_B2G\\modules\\DotNet\\B2Gnow\\Automated\\FileSniffer\\FileSniffer\\Sniffer.cs:line 156\r\n at B2Gnow.Automated.FileSniffer.Sniffer..ctor() in C:\\Data_B2G\\modules\\DotNet\\B2Gnow\\Automated\\FileSniffer\\FileSniffer\\Sniffer.cs:line 37" string
0 votes
by
BTW, the application is being developed in .NET 2.0.
-G
0 votes
by (162k points)
Are you running this code locally or on a web server?

Does the user you are running under have access to this file?
0 votes
by (140 points)
Did this ever get resolved? I'm running the version 2 dll under a c# v2.0 console application, and getting the same issue.

If someone has a fix, please let me know.
0 votes
by (51.6k points)
dunc_nz, though Gilgamesh4Ever didn't reply to my questions, I'm guessing that the problem became obvious once he checked the permissions of the file or directory he/she was accessing. Don't forget that ASP.NET apps don't run under the same user you're logged in as.

- Hans (EDT)
0 votes
by (180 points)
Hi,

If anyone can suggest the code necessary to solve this problem, I'd really appreciate it. I've been going around in circles most of the day trying to determine how to allow this application (windows) to write the downloaded file to the local directory.

I get the following errors:
Access to the path 'c:\\DirectoryName' is denied." -System.Exception {System.UnauthorizedAccessException}


Here's the code:

// Connect, get files and close
ftpConnection1.Connect();

//Change the directory on the remote host
ftpConnection1.ChangeWorkingDirectory("/Directory/Dir1");
ftpConnection1.ChangeWorkingDirectory("/Dir3/Dir4");
// take a look at the files
filesListBox.Items.AddRange(ftpConnection1.GetFiles());
// Indicate the local directory
System.IO.Directory.SetCurrentDirectory(@"c:\DirectoryName\");
// get the file and place it in the local directory
ftpConnection1.DownloadFile(@"c:\DirectoryName", "FileName");

ftpConnection.Close();
0 votes
by (180 points)
Yikes,
These are the ones that hurt...

Here's the change in the code:

ftpConnection1.DownloadFile(@"C:\PdfLogFiles\FileName", "FileName");
//The FileName was missing from the destination path!

I hope this helps, or at least entertains.

Paul
0 votes
by (140 points)
Yikes,
These are the ones that hurt...

Here's the change in the code:

ftpConnection1.DownloadFile(@"C:\PdfLogFiles\FileName", "FileName");
//The FileName was missing from the destination path!

I hope this helps, or at least entertains.

Paul


Thanks! That fixed me up.

This is one of those small usability issues that would be easy to fix.
0 votes
by (51.6k points)
How would you suggest fixing it?

- Hans (EDT Support)

Categories

...