有以下代码:
Console.WriteLine("Sending debt collection file via ftp.");
var filename = Path.GetFileName(filetosend);
// Get the object used to communicate with the server.
var request = (FtpWebRequest)WebRequest.Create(FtpUrl + filename);
request.Method = WebRequestMethods.Ftp.UploadFile;
var secureString = new SecureString();
foreach (var b in Encoding.Default.GetBytes(FtpPassword))
secureString.AppendChar((char)b);
request.Credentials = new NetworkCredential(FtpUsername, secureString);
//request.Credentials = new NetworkCredential("", "");
request.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
var sourceStream = new StreamReader(filetosend);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
var response = (FtpWebResponse) request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
//Console.ReadKey();
response.Close();
我收到了这条消息:
System error.
Please contact Suburban software for assistance.
System error.
at System.Net.FtpWebRequest.GetRequestStream()
at SSS.DebtCollections.FtpToTransworld.Send(String filetosend) in C:\work\ArmEmail\ArmEmail\FtpToTransworld.cs:line 59
at SSS.DebtCollections.Program.Main(String[] args) in C:\work\ArmEmail\ArmEmail\Program.cs:line 44
System error.
at System.Net.PooledStream.PrePush(Object expectedOwner)
at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
我可以使用这个程序从我的开发计算机发送,但工作站给我上面的消息。我不确定是什么。我已将程序添加到允许列表中,并且它在同一网络上运行。
任何建议