首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FTPWebRequest不能得到GetRequestStream

FTPWebRequest不能得到GetRequestStream
EN

Stack Overflow用户
提问于 2016-09-03 20:40:43
回答 1查看 330关注 0票数 0

谢谢你看我的问题。我正在使用FTPWebRequest上传文件,但它不起作用。这是我的密码。

代码语言:javascript
复制
ftp.KeepAlive = false;
ftp.UsePassive = true;

ftp.Method = WebRequestMethods.Ftp.UploadFile;
ftp.UseBinary = true;
ftp.ContentLength = fileInf.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInf.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Stream strm = ftp.GetRequestStream(); <--- Can't get request stream.
contentLen = fs.Read(buff, 0, buffLength);
error = null;

这是网络跟踪

代码语言:javascript
复制
System.Net Information: 0 : [7928] Associating FtpWebRequest#58093648 with FtpControlStream#60452428
System.Net.Sockets Verbose: 0 : [7928] Socket#30630844::Receive()
System.Net.Sockets Verbose: 0 : [7928] Data from Socket#30630844::Receive
System.Net.Sockets Verbose: 0 : [7928] 00000000 : 32 32 30 20 46 54 50 56-69 74 61 20 53 65 72 76 : 220 FTPVita Serv
System.Net.Sockets Verbose: 0 : [7928] 00000010 : 65 72 20 72 65 61 64 79-2E 0A                   : er ready..
System.Net.Sockets Verbose: 0 : [7928] Exiting Socket#30630844::Receive()   -> Int32#26
System.Net.Sockets Verbose: 0 : [7928] Socket#30630844::Receive()

然后抛出一个超时错误。

FTP服务器发送220欢迎消息,但无法获得流。

我试过将UseBinary设置为FALSE,但仍然不起作用。

知道吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2022-06-30 08:32:04

通常,如果您可以登录到服务器,但不能GetRequestStream返回null,则这是正在使用的凭据在服务器上发出的权限问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39311144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档