Home > Net >  C # read from the FTP file stream, after get GetBytes endures byte [], and then save the PDF to the
C # read from the FTP file stream, after get GetBytes endures byte [], and then save the PDF to the

Time:01-17

Get part of the code
Var reqFTP=(FtpWebRequest) WebRequest. Create (new Uri (path + dir + "/" + fileName));
ReqFTP. Method=WebRequestMethods. Ftp. DownloadFile;
ReqFTP. UseBinary=true;
ReqFTP. Proxy=null;//set not use proxy
ReqFTP. Credentials=new NetworkCredential (" administrator ", "* * * * * *");
ReqFTP. UsePassive=true;//select active or passive mode, this sentence with,
ReqFTP. KeepAlive=false;//must set the property, or a one-time download multiple files, can appear abnormal,
FtpWebResponse response=(FtpWebResponse) reqFTP. The method GetResponse ();
Stream ftpStream=response. GetResponseStream ();
StreamReader reader=new StreamReader (ftpStream);
String fileStr=reader. ReadToEnd ();
Reader. The Close ();
FtpStream. Close ();
The response. The Close ();
Return fileStr;
After treatment:
Byte [] byteArray containing=Encoding. The Default. GetBytes (fileStr);
FileStream fs=new FileStream (" C: \ \ Windows \ \ TEMP \ \ CCCCCCCCCCCSSSSSSSSSSSSSS PDF ", FileMode. Create, FileAccess. Write);
Fs. Write (byteArray containing, 0, byteArray containing. Length);
Fs. Flush ();
Fs. The Close ();

Found CCCCCCCCCCCSSSSSSSSSSSSSS. On the PDF blank
PDf and the original PDf file size changed
  •  Tags:  
  • C#
  • Related