p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   General .NET (http://p2p.wrox.com/forumdisplay.php?f=122)
-   -   How to read simple txt file from URL? (http://p2p.wrox.com/showthread.php?t=31959)

takica July 29th, 2005 08:24 AM

How to read simple txt file from URL?
Plz help,
I have problem with reading txt file from URL. I tried with File.OpenText:

filetoread = MapPath("http://www.sitename/file.txt")
Dim filestream As StreamReader
filestream = File.OpenText(filetoread)

And when I run it, Error Message comes:
Map paths expected to be virtual

Does anyone knows how to solve this problem?


mehdi62b August 6th, 2005 01:02 PM

you shuld use WebClient class
the following MSDN example downloads a file from http://www.contoso.com to the local hard drive.

string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);

software student.

All times are GMT -4. The time now is 07:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.