Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
24.7k views
in .NET FTP by (800 points)
I'm trying to upload a zip file using the FTPConnection.UploadFile method, and I keep getting a 550 error, and I can't seem to figure out what the problem in. Below is the code that I'm using, and the error that I'm receiving. If anyone has any idea what's going on and how I can deal with it, I would really appreciate it.

The code:

using( FTPConnection cnx = new FTPConnection() )
{
    this.setupConnection( cnx );

    cnx.Connect();
    if( this.config.RequiresLogin )
    {
        cnx.Login();
    }
    cnx.BytesTransferred += new BytesTransferredHandler( FtpBytesTransferred );
    cnx.ChangeWorkingDirectory( this.config.FolderPath );
    cnx.UploadFile( filepath, filepath.Substring( filepath.LastIndexOf( "\\" ) + 1 ) );
    cnx.BytesTransferred -= new BytesTransferredHandler( FtpBytesTransferred );
}

private void setupConnection( FTPConnection cnx )
{
    cnx.ServerAddress = this.config.Host;
    cnx.UserName = this.config.Username;
    cnx.Password = this.config.Password;
    cnx.ConnectMode = this.config.ConnectMode;
    cnx.TransferType = FTPTransferType.BINARY;
}


The error:

EnterpriseDT.Net.Ftp.FTPException: 200702170948.zip: Access is denied. (code=550)
at EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(FTPReply reply, String[] expectedReplyCodes)
at EnterpriseDT.Net.Ftp.FTPClient.InitPut(String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPClient.PutBinary(Stream srcStream, String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPClient.PutBinary(String localPath, String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile, Boolean append)
at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile)
at BackBurner.Service.FtpClient.UploadFile(String filepath) in C:\MyDir\Visual Studio 2005\Projects\MyApp\MyApp.Service\FtpClient.cs:line 108
at MyApp.Service.Backup.ExportToFTP() in C:\MyDir\Visual Studio 2005\Projects\MyApp\MyApp.Service\Backup.cs:line 346

________________________
// YEX
// John 16:32-33
// http://bob.yexley.net
// http://enjoycharis.com

22 Answers

0 votes
by (162k points)
It looks like you may not have permission to upload a file into that remote directory.
0 votes
by (800 points)
Well...I'm nearly positive that I *do* have permission to upload to that directory, because the application is running as the same user that I use to manually FTP the same file to the same location on the same server. So the permissions should be the same, correct? I don't believe that's the issue.

I have noticed that I seem to get 550 errors in my log window when I manually upload the file using SmartFTP as well. I have no idea why I get those errors, but I do, and SmartFTP seems to just ignore them.
0 votes
by (800 points)
Wow...am I the only one that has encountered this problem/error? I'm really kind of surprised. I'm not sure what to do now...
0 votes
by (162k points)
Since the server is returning the error, there's not much we can do to help. For some reason the server is not permitting you to upload. I don't see how SmartFTP can ignore the errors - in any case if the server is returning 550 it won't be uploading the file.

Try switching between active & passive modes perhaps - maybe the server only allows one of these modes?
0 votes
by (800 points)
Well, I don't really know exactly what's going on either, but I do know for sure that the server *is* returning a 550 error, and the file *is* getting uploaded. Here's my log from SmartFTP where I manually uploaded the file (on both an IIS 6 FTP server and a Linux ProFTP server):

IIS 6 FTP server
==================================
[21:42:25] SmartFTP v2.0.1001.0
[21:42:26] Resolving host name "blah.net"
[21:42:26] Connecting to xx.xx.xx.xx Port: 21
[21:42:26] Connected to balh.net.
[21:42:26] 220 Microsoft FTP Service
[21:42:26] USER xxxxxxx
[21:42:26] 331 Password required for xxxxxxx.
[21:42:26] PASS (hidden)
[21:42:26] 230 User xxxxxxx logged in.
[21:42:26] SYST
[21:42:26] 215 Windows_NT
[21:42:26] Detected Server Type: Windows NT
[21:42:26] FEAT
[21:42:26] 211-FEAT
[21:42:26] SIZE
[21:42:26] MDTM
[21:42:26] 211 END
[21:42:26] TYPE I
[21:42:26] 200 Type set to I.
[21:42:26] REST 0
[21:42:26] 350 Restarting at 0.
[21:42:26] PWD
[21:42:26] 257 "/blah" is current directory.
[21:42:26] CWD /blah/Users/blah/Backup
[21:42:26] 250 CWD command successful.
[21:42:26] PWD
[21:42:26] 257 "/blah/Users/blah/Backup" is current directory.
[21:42:26] TYPE A
[21:42:26] 200 Type set to A.
[21:42:26] PASV
[21:42:26] 227 Entering Passive Mode (192,168,1,7,16,99).
[21:42:27] Opening data connection to 192.168.1.7 Port: 4195
[21:42:27] LIST -aL
[21:42:39] 425 Can't open data connection.
[21:42:39] Automatic failover of data connection mode from "Passive Mode (PASV)" to "Active Mode (PORT)".
[21:42:39] PORT 192,168,1,151,5,69
[21:42:39] 200 PORT command successful.
[21:42:39] LIST -aL
[21:42:39] 150 Opening ASCII mode data connection for /bin/ls.
[21:42:39] 0 bytes transferred. (N/A/s) (0 ms)
[21:42:39] 226 Transfer complete.
[21:43:29] NOOP
[21:43:29] 200 NOOP command successful.
[21:43:36] Remote file exist check: "BackBurner.200703012129.zip".
[21:43:36] TYPE I
[21:43:36] 200 Type set to I.
[21:43:36] SIZE BackBurner.200703012129.zip
[21:43:36] 550 BackBurner.200703012129.zip: The system cannot find the file specified.
[21:43:36] File size check (SIZE) failed. File not found or permission denied.
[21:43:36] PORT 192,168,1,151,5,71
[21:43:36] 200 PORT command successful.
[21:43:36] STOR BackBurner.200703012129.zip
[21:43:36] 150 Opening BINARY mode data connection for BackBurner.200703012129.zip.
[21:43:38] 3030756 bytes transferred. (1.30 MB/s) (00:00:02)
[21:43:38] 226 Transfer complete.
[21:43:38] MDTM 20070302023005 BackBurner.200703012129.zip
[21:43:38] 550 20070302023005 BackBurner.200703012129.zip: The system cannot find the file specified.
[21:43:38] SIZE BackBurner.200703012129.zip
[21:43:39] 213 3030756
[21:43:39] TYPE A
[21:43:39] 200 Type set to A.
[21:43:39] PORT 192,168,1,151,5,73
[21:43:39] 200 PORT command successful.
[21:43:39] LIST -aL
[21:43:39] 150 Opening ASCII mode data connection for /bin/ls.
[21:43:39] 68 bytes transferred. (N/A/s) (0 ms)
[21:43:39] 226 Transfer complete.
[21:43:39] Transfer successful.

Linux ProFTP Server
=====================================
[21:53:49] Resolving host name "blah.com"
[21:53:49] Connecting to xx.xx.xx.xx Port: 21
[21:53:49] Connected to blah.com.
[21:53:49] 220 ProFTPD 1.2.10 Server (ProFTPD) [xx.xx.xx.xx]
[21:53:49] USER xxxxxxxx
[21:53:49] 331 Password required for xxxxxxxx.
[21:53:49] PASS (hidden)
[21:53:50] 230 User xxxxxxxx logged in.
[21:53:50] SYST
[21:53:50] 215 UNIX Type: L8
[21:53:50] Detected Server Type: UNIX
[21:53:50] FEAT
[21:53:50] 211-Features:
[21:53:50] MDTM
[21:53:50] REST STREAM
[21:53:50] SIZE
[21:53:50] 211 End
[21:53:50] PWD
[21:53:50] 257 "/" is current directory.
[21:54:12] CWD /httpdocs/media/temp
[21:54:12] 250 CWD command successful
[21:54:12] PWD
[21:54:12] 257 "/httpdocs/media/temp" is current directory.
[21:54:12] Remote file exist check: "BackBurner.200703012129.zip".
[21:54:12] TYPE I
[21:54:12] 200 Type set to I
[21:54:12] SIZE BackBurner.200703012129.zip
[21:54:12] 550 BackBurner.200703012129.zip: No such file or directory
[21:54:12] File size check (SIZE) failed. File not found or permission denied.
[21:54:12] PASV
[21:54:12] 227 Entering Passive Mode (82,165,240,21,200,29).
[21:54:12] Opening data connection to 82.165.240.21 Port: 51229
[21:54:12] STOR BackBurner.200703012129.zip
[21:54:12] 150 Opening BINARY mode data connection for BackBurner.200703012129.zip
[21:55:22] 3030756 bytes transferred. (42.2 KB/s) (00:01:09)
[21:55:23] 226 Transfer complete.
[21:55:23] MDTM 20070302023005 BackBurner.200703012129.zip
[21:55:23] 550 20070302023005 BackBurner.200703012129.zip: No such file or directory
[21:55:23] SIZE BackBurner.200703012129.zip
[21:55:23] 213 3030756
[21:55:23] TYPE A
[21:55:23] 200 Type set to A
[21:55:23] PASV
[21:55:23] 227 Entering Passive Mode (82,165,240,21,200,45).
[21:55:23] Opening data connection to 82.165.240.21 Port: 51245
[21:55:23] LIST -aL
[21:55:23] 150 Opening ASCII mode data connection for file list
[21:55:23] 210 bytes transferred. (3.25 KB/s) (63 ms)
[21:55:23] 226-Transfer complete.
[21:55:23] 226 Quotas off
[21:55:23] Transfer successful.

I highlighted the pertinent lines from the log above. It seems to me like its somehow just ignoring the 550 errors that are returned. Is there some way I can do something similar with the FTPConnection.UploadFile method? I really need to figure out how to get past this and get this upload working correctly. I'm pretty much at a standstill at the moment. Any ideas would be greatly appreciated.
0 votes
by (800 points)
One other thing too...I'm sure somebody will notice that the error that I'm getting with my code is 550 "Access denied", and the error in the logs posted in the last message is 550 "No such file or directory". I have no idea what the deal is with that. I *have* checked the file and account permissions on both servers though, and I in fact DO have all of the appropriate permissions to be able to upload files without any problems. So I am fairly certain that its not a permissions issue.
0 votes
by (162k points)
Ok, all the 550 errors in your last log file are obviously being ignored by SmartFTP - but these errors are the result of the SIZE command and the MTDM command - which are NOT part of the upload. So they can be ignored without affecting the upload. They are used to obtain information about remote files.

If you are using active mode with FTPConnection it should be able to perform the upload.

We really would need to see the FTPConnection DEBUG log file to comment further ...
0 votes
by (800 points)
I'm fairly certain that it is using ACTIVE mode to attempt the upload. I will do my best to provide a DEBUG log file to help track down this issue, but honestly I'm not real sure how to do that. Is there a good sample (code) somewhere of how to set it up to write to a log?
0 votes
by (162k points)
To set up logging:

FTPConnection.LogFile = "mylog.log";
FTPConnection.LogLevel = LogLevel.Debug;
0 votes
by (800 points)
Thanks very much. I'll give that a shot, and provide additional log information as soon as I can.

Categories

...