.NET Components for Mobility

How to use WebClient

Last post 07-02-2008 2:54 PM by PeterFoot. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-31-2007 8:07 AM

    How to use WebClient

    I've been playing around with the FtpClient Sample that comes with this library and so far it's working perfectly. Before finding your libraries the other day, I'd previously done some tests with my own http file transfer to download a file onto a Pocket PC. That worked fine but I could not make upload work so I thought I'd try your HttpWebRequest class. Currently I don't actually need upload but it bugged me that I couldn't make it work.

    I see in your blog that you have a WebClient sample that you recommend over using the HttpWebRequest class. When I click on the link in the blog (or any similar link), I get an "opps something went wrong" message.

    It would be great if I could try the WebClient sample rather than knocking up a test program of my own.

    My other question is about which protocol to use. I'm in control of both the software on the Pocket PC and the server so I can probably use either protocol but can't decide which is best so any advice much appreciated. I'll be using the file transfer to download large program updates to the Pocket PC. I'll have some kind of loader/checker program that will check for a new version of the software at the server. I will also be downloading updated (fairly static) data that is shown within the application in dropdown lists etc.

    Regards,

    John.

  • 01-02-2008 5:57 AM In reply to

    Re: How to use WebClient

    Further to the above, I tried using the WebClient class to upload and download files via http. Download works fine but when I try to upload a file I get an exception of:

    "Either ContentLength must be set to a non-negative number, or SendChunked set to true in order to perform the write operation when AllowWriteStreamBuffering is disabled"

    I can't see how I can set any of these properties if all I am using is the WebClient class.

    I also don't understand why WebClient.DownloadFile does not need to specify a method while UploadFile does have the option of specifying a method. I assume DownloadFile susses the protocol from the URL used - http:// as opposed to ftp://

    Regards,

    John.

  • 01-18-2008 7:49 AM In reply to

    Re: How to use WebClient

    When using Upload the method could use either POST or PUT but Download always uses GET (for http). I'll look into the content length message and post back with details.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
  • 07-02-2008 6:13 AM In reply to

    Re: How to use WebClient

    Does the FTPClient example require the full NetworkingInTheHand application?

    I only ask because I cannot get it to run with the evaluation software. If not, then are there any other examples on here which I could view before I decide to purchase this software?

  • 07-02-2008 11:55 AM In reply to

    Re: How to use WebClient

    I expect you'll need Peter to help with your real problem but I can confirm FTPClient works in the evaluation version because that was I tested with at first.

    What actual problem are you getting?

    John.

  • 07-02-2008 2:54 PM In reply to

    Re: How to use WebClient

    Yes the example will work with the evaluation version. What specific problem do you have?

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
Page 1 of 1 (6 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.