我需要上载一些DATA的服务器和FTP服务器。
跟踪盘点后,如何在燃料循环基金内部卸载燃料和燃料循环基金所有工作。
现在我正在努力改进我的上载。
相反,收集DATA,将其写给FLE公司,然后将档案上载到FTP内,以便收集DATA,在不创建当地档案的情况下将其上载。
为此:
string uri = "ftp://" + ftpServerIp + "/" + fileToUpload.Name;
System.Net.FtpWebRequest reqFTP;
// Create FtpWebRequest object from the Uri provided
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIp + "/" + fileToUpload.Name));
// Provide the WebPermission Credintials
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
// By default KeepAlive is true, where the control connection is not closed after a command is executed.
reqFTP.KeepAlive = false;
// Specify the command to be executed.
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
// Specify the data transfer type.
reqFTP.UseBinary = true;
byte[] messageContent = Encoding.ASCII.GetBytes(message);
// Notify the server about the size of the uploaded file
reqFTP.ContentLength = messageContent.Length;
int buffLength = 2048;
// Stream to which the file to be upload is written
Stream strm = reqFTP.GetRequestStream();
// Write Content from the file stream to the FTP Upload Stream
int total_bytes = (int)messageContent.Length;
while (total_bytes > 0)
{
strm.Write(messageContent, 0, buffLength);
total_bytes = total_bytes - buffLength;
}
strm.Close();
现在情况如下:
- i see the client connecting to the server
- the file is created
- no data are transferred
- at some point the thread is terminated the connection is closed
- if i inspect the uploaded file is empty.
意欲转让的DATA是一件战略文件,这就是为什么要发出信息Content = 编码。
什么是错了?
此外,如果与ASCII号编码相联。 遥远服务器上的GetBytes将拥有一个短信文档或一个与一些Bytes的档案?
感谢您提出任何建议