.net - The remote server returned an error (550) file unavailable (e.g. File not found no access) -


the remote server returned error (550) file unavailable (e.g. file not found no access).

when downloading 2 files 1 21 bytes date.txt file , 1 around 2 gb .zip file. zip file downloading when date.txt downloading getting error:

i trying code file download ftp.:

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; // key 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 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();         }         // remove 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;     } }  


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -