Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

downloading a file from internet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DBC User - 29 Aug 2006 19:33 GMT
I am planning to stage couple small text files in one of my personal
web site. Which is running in linux. I writing a .net app, I want to
download and see the content inside. Could someone tell me what do I
need to know and setup so that my app can get the files without any
problem??

Thanks a lot.
Peter Bromberg [C# MVP] - 29 Aug 2006 19:48 GMT
WebClient wc = new WebClient();
                   byte[] b = wc.DownloadData(urlToYourResource);
                   wc.Dispose();
                   string strContent =
System.Text.Encoding.UTF8.GetString(b);

--Peter
-
Signature

Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

> I am planning to stage couple small text files in one of my personal
> web site. Which is running in linux. I writing a .net app, I want to
[quoted text clipped - 3 lines]
>
> Thanks a lot.
DBC User - 29 Aug 2006 19:55 GMT
Hi Peter,
Thanks for the help. One quick question, do I need to setup anything on
my server so that anyone read this file?
Thanks again.
Peter wrote:
> WebClient wc = new WebClient();
>                     byte[] b = wc.DownloadData(urlToYourResource);
[quoted text clipped - 17 lines]
> >
> > Thanks a lot.
Mel - 29 Aug 2006 20:33 GMT
No, you do not need to setup anything on the your server.

> Hi Peter,
> Thanks for the help. One quick question, do I need to setup anything on
[quoted text clipped - 22 lines]
>> >
>> > Thanks a lot.
DBC User - 30 Aug 2006 16:16 GMT
Thanks.
> No, you do not need to setup anything on the your server.
>
[quoted text clipped - 24 lines]
> >> >
> >> > Thanks a lot.
Joerg Jooss - 29 Aug 2006 20:01 GMT
Thus wrote Peter Bromberg [C# MVP],

> WebClient wc = new WebClient();
> byte[] b = wc.DownloadData(urlToYourResource);
> wc.Dispose();
> string strContent =
> System.Text.Encoding.UTF8.GetString(b);
> --Peter

With .NET 2.0, you can also use DownloadString():

WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string content = wc.DownloadString(url);

Cheers,
Signature

Joerg Jooss
news-reply@joergjooss.de


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.