繁体   English   中英

Windows Phone 7 Ftp客户端

[英]Windows Phone 7 Ftp client

我正在使用visual studio和使用Windows Phone 7开发智能手机ftp客户端

我面临着一些错误

request.Method = WebRequestMethods.ftp.ListDirectory

错误1目标平台不支持后期绑定。 C:\\ Users \\ Zaheer \\ Documents \\ Visual Studio 2010 \\ Projects \\ PhoneApp4 \\ PhoneApp4 \\ MainPage.xaml.vb 36 30 PhoneApp4

response = CType(request.GetWebResponse(),WebResponse)错误2'GetWebResponse'不是'System.Net.WebRequest'的成员。 C:\\ Users \\ Zaheer \\ Documents \\ Visual Studio 2010 \\ Projects \\ PhoneApp4 \\ PhoneApp4 \\ MainPage.xaml.vb 37 30 PhoneApp4

这是完整的代码请帮帮我

    Dim Request As WebRequest = Nothing
    Dim Response As WebResponse = Nothing
        Dim reader As StreamReader = Nothing
        Dim Port As Integer = 21
        Try
        Request = CType(WebRequest.Create(URL), WebRequest)
            Request.Method = "List"

        Request.Credentials = New NetworkCredential(Username, Password)
        Request.Method = WebRequestMethods.Ftp.ListDirectory
        Response = CType(Response.GetWebRequest(), WebResponse)
            reader = New StreamReader(Response.GetResponseStream())
            While (reader.Peek() > -1)
                RemoteSite.Items.Add(reader.ReadLine())
            End While
        Catch ex As Exception
            Console.WriteLine("List Sucessfully.")
        End Try
    End Sub

对于后期绑定错误,您需要将要设置的对象强制转换为正确的数据类型,因为WP7不支持类型的运行时评估(后期绑定)。

至于GetWebResponse的错误,编译器绝对正确, WebRequest (甚至HttpWebRequest )没有GetWebResponse方法,也许你正在寻找WebRequest.GetResponse

例如:

response = request.GetResponse(); // where request is of type WebRequest or a derived class

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM