我正在使用FTP将一个XML文件上传到 Web 服务器
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上传文件吗?我的代码上传文件是否正确?