首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在windows中找不到FtpWebRequest

在windows中找不到FtpWebRequest
EN

Stack Overflow用户
提问于 2013-07-24 13:07:09
回答 1查看 496关注 0票数 0

我正在使用FTP将一个XML文件上传到web服务器。

代码语言:javascript
复制
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("test.xml", FileMode.Append, myIsolatedStorage))
            {
                FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri"ftp://" + IPServer + "/" + isoStream.Name));
                reqFTP.UsePassive = true;
                reqFTP.UseBinary = true;
                reqFTP.Credentials = new NetworkCredential("uname", "pass");
                reqFTP.Method = WebRequestMethods.Ftp.UploadFile;


                int bufferLength = 2048;
                byte[] buffer = new byte[bufferLength];

                Stream uploadStream = reqFTP.GetRequestStream();
                int contentLength = isoStream.Read(buffer, 0, bufferLength);

                while (contentLength != 0)
                {
                    uploadStream.Write(buffer, 0, bufferLength);
                    contentLength = isoStream.Read(buffer, 0, bufferLength);
                }
            }

但我找不到FtpWebRequest.我还添加了程序集System.Net。我不明白有什么问题吗?有人能帮我解决这个问题吗?我可以在windows中使用FtpWebRequest上传文件吗?我的代码上传文件是否正确?

EN

回答 1

Stack Overflow用户

发布于 2013-07-24 13:10:44

目前,Windows中还没有FtpWebRequest

同样的问题被问到其他地方让人们提到使用一个在HTTP中封装FTP调用的服务。这似乎是你现在唯一的选择,除非你找到一些第三方组件来使用。

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

https://stackoverflow.com/questions/17834932

复制
相关文章

相似问题

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