Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
24.1k 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 (800 points)
Uummm...what version of edtFTPnet library has the FTPConnection object with the LogFile and LogLevel properties? Apparently an earlier or later version than the one I'm using, because my FTPConnection object doesn't have either of those properties.
0 votes
by (800 points)
Disregard that last...sorry. Apparently 1.2.4 has those properties...I've been using 1.2.3. Upgrading now.
0 votes
by (800 points)
OK...so I upgraded (not sure if it was really necessary or not...I was looking for LogFile and LogLevel instance properties, not static properties...so they may have been there and I just didn't notice it, sorry for the confusion if so), and set those values, and tried again. Here's the log information:

DEBUG [HostNameResolver] 2 Mar 2007 23:15:38.846 : mydomain.net resolved to xxx.xxx.xxx.xxx
DEBUG [FTPClient] 2 Mar 2007 23:15:38.861 : Connecting to xxx.xxx.xxx.xxx:21
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:38.940 : 220 Microsoft FTP Service
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:38.955 : ---> USER blah
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:38.955 : 331 Password required for blah.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:38.955 : ---> PASS ********
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : 230 User blah logged in.
DEBUG [FTPConnection] 2 Mar 2007 23:15:39.158 : Successfully logged in
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : ---> TYPE I
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : 200 Type set to I.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : ---> PWD
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : 257 "/blah" is current directory.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : ---> USER blah
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : 331 Password required for blah.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.158 : ---> PASS ********
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.174 : 230 User blah logged in.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.174 : ---> CWD /Users/blah/Backup
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.190 : 250 CWD command successful.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.190 : ---> PWD
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.190 : 257 "/Users/blah/Backup" is current directory.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.205 : NewActiveDataSocket(0)
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.205 : ---> PORT xxx,xxx,x,xxx,7,29
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.221 : 200 PORT command successful.
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.221 : ---> STOR 200703022315.zip
DEBUG [FTPControlSocket] 2 Mar 2007 23:15:39.221 : 550 200703022315.zip: Access is denied.
DEBUG [FTPClient] 2 Mar 2007 23:15:39.252 : Transferred 0 bytes to remote host

So, yeah...it does still appear that I don't have permissions. However, we know that I do...I can do it manually with multiple different other clients. I have checked the permissions on the server, and I do have the correct permissions as far as I can tell. I mean, there aren't any other settings that I can set. I've even tried changing the NTFS permissions on the directories that the FTP virtual directory I'm connecting to exposes, and that didn't seem to make any difference either. Anyone have any ideas at all why this would be happening? This application will most assuredly be used against other IIS FTP servers, so I really need to figure out a way to make this work. What could be wrong? I just don't get it.
0 votes
by (161k points)
Perhaps the server doesn't like the name '200703022315.zip'?

Try one like the SmartFTP client was using, e.g. 'BackBurner.200703012129.zip'.
0 votes
by (800 points)
OK, I changed the code that sets the filename. Its set to something pretty plain and, seemingly, safe now. Tried it again. Same result. Here's the log:

DEBUG [HostNameResolver] 2 Mar 2007 23:37:16.061 : yexley.net resolved to 192.168.1.7
DEBUG [FTPClient] 2 Mar 2007 23:37:16.061 : Connecting to 192.168.1.7:21
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.077 : 220 Microsoft FTP Service
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.077 : ---> USER blah
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.077 : 331 Password required for blah.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.077 : ---> PASS ********
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.092 : 230 User blah logged in.
DEBUG [FTPConnection] 2 Mar 2007 23:37:16.092 : Successfully logged in
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.092 : ---> TYPE I
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 200 Type set to I.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : ---> PWD
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 257 "/blah" is current directory.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : ---> USER blah
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 331 Password required for blah.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : ---> PASS ********
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 230 User blah logged in.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : ---> CWD /Users/blah/Backup
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 250 CWD command successful.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : ---> PWD
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.108 : 257 "/Users/blah/Backup" is current directory.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.124 : NewActiveDataSocket(0)
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.124 : ---> PORT 192,168,1,151,7,156
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.124 : 200 PORT command successful.
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.124 : ---> STOR BackBurner.zip
DEBUG [FTPControlSocket] 2 Mar 2007 23:37:16.124 : 550 BackBurner.zip: Access is denied.
DEBUG [FTPClient] 2 Mar 2007 23:37:16.139 : Transferred 0 bytes to remote host

Could it possibly be something with the encoding? Do I need to set the transfer encoding for the connection or something like that maybe?
0 votes
by (161k points)
Can you connect to the same server with the same credentials using SmartFTP and try uploading the same file, and post the log?

If one client works, so should another.

PS It may be that SmartFTP is using a certain port range for active mode. Check the config - that can be set in edtFTPnet too.
0 votes
by (800 points)
Here's the log from my successful upload of the file with SmartFTP. Looks like you might be onto something...it appears that the ports that its using are strange...to me anyway. I'm not *exactly* sure what I should be looking for here either. Here's the log:

[08:51:38] SmartFTP v2.0.1001.0
[08:51:39] Resolving host name "myserver.net"
[08:51:39] Connecting to 192.168.1.7 Port: 21
[08:51:39] Connected to yexley.net.
[08:51:40] 220 Microsoft FTP Service
[08:51:40] USER blah
[08:51:40] 331 Password required for blah.
[08:51:40] PASS (hidden)
[08:51:40] 230 User blah logged in.
[08:51:40] SYST
[08:51:40] 215 Windows_NT
[08:51:40] Detected Server Type: Windows NT
[08:51:40] FEAT
[08:51:40] 211-FEAT
[08:51:40] SIZE
[08:51:40] MDTM
[08:51:40] 211 END
[08:51:40] TYPE I
[08:51:40] 200 Type set to I.
[08:51:40] REST 0
[08:51:40] 350 Restarting at 0.
[08:51:40] PWD
[08:51:40] 257 "/blah" is current directory.
[08:51:40] CWD /blah/Users/blah/Backup
[08:51:40] 250 CWD command successful.
[08:51:40] PWD
[08:51:40] 257 "/blah/Users/blah/Backup" is current directory.
[08:51:40] TYPE A
[08:51:40] 200 Type set to A.
[08:51:40] PASV
[08:51:40] 227 Entering Passive Mode (192,168,1,7,5,68).
[08:51:40] Opening data connection to 192.168.1.7 Port: 1348
[08:51:40] LIST -aL
[08:51:52] 425 Can't open data connection.
[08:51:52] Automatic failover of data connection mode from "Passive Mode (PASV)" to "Active Mode (PORT)".
[08:51:52] PORT 192,168,1,151,4,188
[08:51:52] 200 PORT command successful.
[08:51:52] LIST -aL
[08:51:52] 150 Opening ASCII mode data connection for /bin/ls.
[08:51:52] 0 bytes transferred. (0 bytes/s) (16 ms)
[08:51:52] 226 Transfer complete.
[08:52:10] Remote file exist check: "BackBurner.zip".
[08:52:10] TYPE I
[08:52:10] 200 Type set to I.
[08:52:10] SIZE BackBurner.zip
[08:52:10] 550 BackBurner.zip: The system cannot find the file specified.
[08:52:10] File size check (SIZE) failed. File not found or permission denied.
[08:52:10] PORT 192,168,1,151,4,190
[08:52:10] 200 PORT command successful.
[08:52:10] STOR BackBurner.zip
[08:52:10] 150 Opening BINARY mode data connection for BackBurner.zip.
[08:52:13] 3030719 bytes transferred. (1.31 MB/s) (00:00:02)
[08:52:13] 226 Transfer complete.
[08:52:13] MDTM 20070303051133 BackBurner.zip
[08:52:13] 550 20070303051133 BackBurner.zip: The system cannot find the file specified.
[08:52:13] SIZE BackBurner.zip
[08:52:13] 213 3030719
[08:52:13] TYPE A
[08:52:13] 200 Type set to A.
[08:52:13] PORT 192,168,1,151,4,192
[08:52:13] 200 PORT command successful.
[08:52:13] LIST -aL
[08:52:13] 150 Opening ASCII mode data connection for /bin/ls.
[08:52:13] 55 bytes transferred. (N/A/s) (0 ms)
[08:52:13] 226 Transfer complete.
[08:52:13] Transfer successful.
0 votes
by (800 points)
So, I tried setting the ActivePortRange property on my connection object, but I can't figure out how to do that. I keep getting an error that tells me that "The type 'EnterpriseDT.Net.Ftp.PortRange' has no constructors defined". How do I set this property if I can't create a PortRange object? Is there a factory that I need to use to get one or something like that?
0 votes
by (161k points)
You just set the ports, e.g.

ftp.ActivePortRange.LowPort = 1200;
ftp.ActivePortRange.HighPort= 1300;
0 votes
by (800 points)
Well, sadly, that doesn't seem to make any difference either. I still get the same errors when I upload, no matter what port range I seem to use. Any other ideas or thoughts?

Categories

...