【发布时间】:2013-07-24 21:10:44
【问题描述】:
我正在使用 FTP
将一个 XML 文件上传到网络服务器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 phone 中使用 FtpWebRequest 上传文件吗?我的代码是否正确上传文件?
【问题讨论】:
标签: c# windows-phone-7 windows-phone-8 isolatedstorage ftpwebrequest