如何在UWP中创建FTP连接?

时间:2016-05-02 17:21:09

标签: c# ftp win-universal-app universal

我想编写一个简单的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中找不到此选项。

1 个答案:

答案 0 :(得分:1)