我想编写一个简单的FTP客户端UWP程序,但是当我创建WebResponse时它会引发异常:
只允许'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中找不到此选项。
答案 0 :(得分:1)