如何在 UWP 中创建 FTP 连接?
How to create FTP connection in UWP?
我想编写一个简单的 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 中找不到这个选项。
你可以试试Chilkat FTP component or WinRT sample: Windows 8.1 Sockets: Ftp Client Sample with Sockets in C#/Xaml
我想编写一个简单的 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 中找不到这个选项。
你可以试试Chilkat FTP component or WinRT sample: Windows 8.1 Sockets: Ftp Client Sample with Sockets in C#/Xaml