我想編寫一個簡單的FTP客戶端程序UWP,但是當我創建WebResponse的它拋出一個異常:如何在UWP中創建FTP連接?
只有「HTTP」和「HTTPS」方案是允許的。
private async void ListDirectory()
{
var obj = App.Current as App;
WebRequest request = WebRequest.Create(obj.ServerUri);
if (obj.credential != null)
{
request.Credentials = obj.credential;
}
request.Method = "LIST";
using (WebResponse response = await request.GetResponseAsync()) // the exception is here
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(responseStream))
{
string item = reader.ReadLine();
// add to list etc...
}
}
}
}
我在此之後在互聯網上搜索,我發現,我必須啓用SSL,但我找不到在Visual Studio該選項2015年
嘗試使用FtpWebRequest(如果可用於UWP):https://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest(v = vs.110).aspx – ZippyV