Удаленный сервер вернул ошибку (550) файл недоступен (например, файл не найден нет доступа)
Привет,
The remote server returned an error (550) file unavailable (e.g. file not found no access).
Когда я загружаю два файла один только 21 байт Date.txt файл и еще один около 2 ГБ. zip-файл.
Загрузка Zip-файла успешно, но когда Date.txt была загрузка так что его получение ошибки:
Пожалуйста, помогите мне.
Как это можно разрешить?
заранее спасибо.
Анкит Агарвал
инженер-программист
Что я уже пробовал:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string[] files = ReadFileList(); FTPSettings.IP = "xx.xx.xxx.xxx/TextureData"; FTPSettings.UserID = "xxxx"; FTPSettings.Password = "xxx"; //FtpWebRequest reqFTP = null; //Stream ftpStream = null; foreach (string file in files) { //string fileName = e.Argument.ToString(); FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + FTPSettings.IP + "/" + file); request.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password); request.Method = WebRequestMethods.Ftp.GetFileSize; request.Proxy = null; long fileSize; // this is the key for ReportProgress using (WebResponse resp = request.GetResponse()) fileSize = resp.ContentLength; request = (FtpWebRequest)WebRequest.Create("ftp://" + FTPSettings.IP + "/" + file); request.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password); request.Method = WebRequestMethods.Ftp.DownloadFile; using (FtpWebResponse responseFileDownload = (FtpWebResponse)request.GetResponse()) using (Stream responseStream = responseFileDownload.GetResponseStream()) using (FileStream writeStream = new FileStream(@"C:\Program Files (x86)\xxxx\" + file, FileMode.Create)) { int Length = 2048; Byte[] buffer = new Byte[Length]; int bytesRead = responseStream.Read(buffer, 0, Length); int bytes = 0; while (bytesRead > 0) { writeStream.Write(buffer, 0, bytesRead); bytesRead = responseStream.Read(buffer, 0, Length); bytes += bytesRead;// don't forget to increment bytesRead ! int iProgress = 0; int totalSize = (int)(fileSize) / 1000; // Kbytes if (totalSize > 0) { iProgress = (bytes / 1000) * 100 / totalSize; } backgroundWorker1.ReportProgress(iProgress, totalSize); } } string zipFileExtension = Path.GetExtension(file); if (zipFileExtension == ".zip") { string zipToUnpack = @"C:\Program Files (x86)\xxxx\" + file; string unpackDirectory = @"C:\Program Files (x86)\xxxx\"; using (ZipFile zip1 = ZipFile.Read(zipToUnpack)) { foreach (ZipEntry ze in zip1) { ze.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently); } } } } } public static class FTPSettings { public static string IP { get; set; } public static string UserID { get; set; } public static string Password { get; set; } } public string[] ReadFileList() { //Debugger.Break(); string[] mydownloadFiles; StringBuilder myresult = new StringBuilder(); //WebResponse myresponse = null; StreamReader myreader = null; FtpWebRequest myreqFTP = null; try { FTPSettings.IP = "xx.xx.xxx.xxx/TextureData"; FTPSettings.UserID = "xxxx"; FTPSettings.Password = "xxxx"; myreqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + FTPSettings.IP + "/")); myreqFTP.Method = WebRequestMethods.Ftp.ListDirectory; myreqFTP.UseBinary = true; myreqFTP.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password); FtpWebResponse response = (FtpWebResponse)myreqFTP.GetResponse(); myreader = new StreamReader(response.GetResponseStream()); string myline = myreader.ReadLine(); while (myline != null) { myresult.Append(myline); myresult.Append("\n"); myline = myreader.ReadLine(); } // to remove the trailing '\n' myresult.Remove(myresult.ToString().LastIndexOf('\n'), 1); return myresult.ToString().Split('\n'); } catch (Exception ex) { if (myreader != null) { myreader.Close(); } mydownloadFiles = null; return mydownloadFiles; }