如何在UWP中创建FTP连接



我想写一个简单的FTP客户端UWP程序,但当我创建WebResponse时,它抛出了一个异常:

只允许使用"http"one_answers"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中找不到这个选项。

您可以尝试Chilkat FTP组件或WinRT示例:Windows 8.1套接字:FTP客户端示例,带有C#/Xaml 中的套接字

最新更新