Windows Phone 7 FTP 客户端 [英] Windows Phone 7 Ftp client

查看:34
本文介绍了Windows Phone 7 FTP 客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i am developing smartphone ftp client using visual studio and using windows phone 7

我正面临一些错误,例如

i am facing some errors like

request.Method = WebRequestMethods.ftp.ListDirectory

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

Error 1 The targeted platform does not support latebinding. C:\Users\Zaheer\Documents\Visual Studio 2010\Projects\PhoneApp4\PhoneApp4\MainPage.xaml.vb 36 30 PhoneApp4

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

response = CType(request.GetWebResponse(), WebResponse) Error 2 'GetWebResponse' is not a member of '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 不支持类型的运行时评估(后期绑定).

For the late binding error, you need to cast the object you are trying to set to the correct data type, as WP7 doesn't support runtime evaluation of types (late-binding).

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

As for the error with GetWebResponse, the compiler is absolutely correct, WebRequest (or even HttpWebRequest) does not have a GetWebResponse method, perhaps you were looking for WebRequest.GetResponse?

例如:

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

这篇关于Windows Phone 7 FTP 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆