C# FTP: Error 530

Nick_SMI

Ensign
Registriert
Sep. 2015
Beiträge
153
Hallo zusammen.

Ich bin gerade dabei, bei einem Programm einen FTP-Download hinzuzufügen.
Nun, folgender Code:

Code:
ftp ftpClient = new ftp(@"ftp://meinServer", "meinUsername", "meinPasswort");
ftpClient.download("xy/test.txt", @Properties.Settings.Default.Pfad); //Diese Propertie beinhaltet einen Pfad!

ftp-Class:
Code:
        /* Construct Object */
        public ftp(string hostIP, string userName, string password) { host = hostIP; user = userName; pass = password; }

        /* Download File */
        public void download(string remoteFile, string localFile)
        {
            try
            {
                /* Create an FTP Request */
                ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + remoteFile);
                /* Log in to the FTP Server with the User Name and Password Provided */
                ftpRequest.Credentials = new NetworkCredential(user, pass);
                /* When in doubt, use these options */
                ftpRequest.UseBinary = true;
                ftpRequest.UsePassive = true;
                ftpRequest.KeepAlive = true;
                /* Specify the Type of FTP Request */
                ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
                /* Establish Return Communication with the FTP Server */
                ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                /* Get the FTP Server's Response Stream */
                ftpStream = ftpResponse.GetResponseStream();
                /* Open a File Stream to Write the Downloaded File */
                FileStream localFileStream = new FileStream(localFile, FileMode.Create);
                /* Buffer for the Downloaded Data */
                byte[] byteBuffer = new byte[bufferSize];
                int bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
                /* Download the File by Writing the Buffered Data Until the Transfer is Complete */
                try
                {
                    while (bytesRead > 0)
                    {
                        localFileStream.Write(byteBuffer, 0, bytesRead);
                        bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error at ftp", MessageBoxButton.OK, MessageBoxImage.Error); }
                /* Resource Cleanup */
                localFileStream.Close();
                ftpStream.Close();
                ftpResponse.Close();
                ftpRequest = null;
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error at ftp", MessageBoxButton.OK, MessageBoxImage.Error); }
            return;
        }

Nicht nur Copy&Paste, den Code dahinter habe ich verstanden!
Aber ich kriege einen Error 530 zurück, der meldet, dass ich nicht angemeldet bin!?


Hoffe ihr wisst weiter, danke im voraus!
Nick
 
Zurück
Oben