Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
9.6k views
in .NET FTP by
I always get the error that the programm can't find my file. It only works if I copy the file into the C:/winnt/system32 directory and with no path in the filename. Does anyone has an idea where the problem is ?

7 Answers

0 votes
by (161k points)
Maybe you need "d:\\benutzer.txt", i.e. escape the backslash.

I always get the error that the programm can't find my file. It only works if I copy the file into the C:/winnt/system32 directory and with no path in the filename. Does anyone has an idea where the problem is ?
0 votes
by
Well I already used the path "d:\\benutzer.txt". But if its displayed in the error message its only one backslash.
There are two arguments. One is the filename and one is the directory. But i think the directory-argument is only for the remote-server...
Does anyone has an example for transfering a file from a different directory than the system32 ??

Thanks
0 votes
by
It says:
[FTPException: D:\Testseite_Intern\vs_Projekte\Gemeindekanal\preview.css: Die Syntax fr den Dateinamen, Verzeichnisnamen oder die Datentrgerbezeichnung ist falsch. ]
   EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(String reply, String[] expectedReplyCodes) +155
   EnterpriseDT.Net.Ftp.FTPClient.InitPut(String remoteFile, Boolean append) +137
   EnterpriseDT.Net.Ftp.FTPClient.PutBinary(Stream srcStream, String remoteFile, Boolean append) +46
   EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile) +99
   Gemeindekanal.ftp.Page_Load(Object sender, EventArgs e) in h:\vs_projekte\gemeindekanal\ftp.aspx.cs:80
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731


The message means that the syntax of the file or directory is wrong.
0 votes
by (161k points)
Can you post the code fragment?
0 votes
by
Ok here it is. What i found out is that I can only transfer binary files from the system32 directory. For example I cant transfer a .txt file from the system32. I get the error that there isn't such a file although I copied it into the directory.

   string host = "www.oxymoron.li";
   string user = "bjelan";
   string password = "********";
   string filename = Server.MapPath("preview.css");
   string mode = "ASCII";
   string connMode = "PASV";
   
   // connect and test supplying port no.
            FTPClient ftp = new FTPClient(host, 21);
            ftp.Login(user, password);
            ftp.Quit();

            // connect again
            ftp = new FTPClient(host);

            // switch on debug of responses
            ftp.DebugResponses(true);

            ftp.Login(user, password);

            // binary transfer
            if (mode.ToUpper() == "BINARY") 
            {
               ftp.TransferType = FTPTransferType.BINARY;
            }
            else if (mode.ToUpper() == "ASCII") 
            {
               ftp.TransferType = FTPTransferType.ASCII;
            }
            else 
            {
               Response.Write("Unknown transfer type:");
               
            }

            // PASV or active?
            if (connMode.ToUpper() == "PASV") 
            {
               ftp.ConnectMode = FTPConnectMode.PASV;
            }
            else if (connMode.ToUpper() == "ACTIVE") 
            {
               ftp.ConnectMode = FTPConnectMode.ACTIVE;
            }
            else 
            {
               Response.Write("Unknown connect mode: ");
               
            }

            
            // put a local file to remote host
            ftp.Put(filename, filename);

            ftp.Quit();
0 votes
by (161k points)
I don't follow this line, below. Isn't filename="d:\\whatever.txt" or something like that?

If this is the case - FTP servers don't understand drive letters.


   // put a local file to remote host
       ftp.Put(filename, filename);
0 votes
by
Well that was exactly the line which made problems. I replaced the second argument with the filename without the path and it worked. The reason for this codeline was because in the FTPTest.cs file is exactly this line and i copied it into my asp.net file.

But thanks a lot !

Categories

...