C# ftp EndGetRequestStream
C# ftp EndGetRequestStream
您好,我的 FTP 服务器有问题。
让我解释一下:
我制作了一个工具,可以将 .png 文件上传到我的 FTP。
当我在当然之间有一些延迟上传 2 张图片时.. 并尝试上传第三张。我收到超时错误。我认为这是因为我需要结束直播。但我不确定如何使用 FtpWebRequest.EndGetRequestStream。有人知道吗?
如果您需要,这是我的代码:
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://www.mysite.com/public_html/" + name);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("MyFTPUsername", "MyFTPPassword");
request.UseBinary = true;
request.UsePassive = true;
request.KeepAlive = true;
shot = sc.CaptureWindow(HandleID);// Here i take a screenshot of my active window
shot.Save(request.GetRequestStream(), ImageFormat.Png);// Here i upload it to the FTP
request.EndGetRequestStream();// <-- - Now i (think) need to end the stream. But i am not sure how to use the parameters
谢谢!
(如有不明白的地方还请多多指教!)
可能只需要调用 request.GetRequestStream() 而不是 request.EndGetRequestStream()?
更新:
抱歉,我的意思是调用 request.GetResponse() 而不是 request.EndGetRequestStream()。
您好,我的 FTP 服务器有问题。 让我解释一下:
我制作了一个工具,可以将 .png 文件上传到我的 FTP。 当我在当然之间有一些延迟上传 2 张图片时.. 并尝试上传第三张。我收到超时错误。我认为这是因为我需要结束直播。但我不确定如何使用 FtpWebRequest.EndGetRequestStream。有人知道吗?
如果您需要,这是我的代码:
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://www.mysite.com/public_html/" + name);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("MyFTPUsername", "MyFTPPassword");
request.UseBinary = true;
request.UsePassive = true;
request.KeepAlive = true;
shot = sc.CaptureWindow(HandleID);// Here i take a screenshot of my active window
shot.Save(request.GetRequestStream(), ImageFormat.Png);// Here i upload it to the FTP
request.EndGetRequestStream();// <-- - Now i (think) need to end the stream. But i am not sure how to use the parameters
谢谢!
(如有不明白的地方还请多多指教!)
可能只需要调用 request.GetRequestStream() 而不是 request.EndGetRequestStream()?
更新:
抱歉,我的意思是调用 request.GetResponse() 而不是 request.EndGetRequestStream()。