我想编写一个简单的 FTP 客户端 UWP 程序,但是当我创建 WebResponse 时它抛出异常:
Only 'http' and 'https' schemes are allowed.
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 中找不到这个选项。
我是一名优秀的程序员,十分优秀!