Home All Groups Group Topic Archive Search About

Using Streamreader with files in servers

Author
7 May 2006 5:38 PM
Ismaelf
hello!, is there any way that streamreader can be used to read a file
published in a web server, ex: "http://localhost/text.txt"
or is there any other way of reading such file??, thanks!

Author
7 May 2006 5:56 PM
Michel Posseth [MCP]
No not with a stream reader , however you could just use a webclient to
retrieve anny file that is server by a webserver
the only thing you need is the web location

regards

Michel Posseth [MCP]


Show quoteHide quote
"Ismaelf" <isma***@gmail.com> schreef in bericht
news:1147023511.888857.144860@j33g2000cwa.googlegroups.com...
> hello!, is there any way that streamreader can be used to read a file
> published in a web server, ex: "http://localhost/text.txt"
> or is there any other way of reading such file??, thanks!
>
Author
7 May 2006 6:58 PM
Herfried K. Wagner [MVP]
"Ismaelf" <isma***@gmail.com> schrieb:
> hello!, is there any way that streamreader can be used to read a file
> published in a web server, ex: "http://localhost/text.txt"
> or is there any other way of reading such file??

<URL:http://dotnet.mvps.org/dotnet/code/net/#InternetLoadFile>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
8 May 2006 2:31 AM
Ismaelf
ohh thanks alot, this really helped!
Author
8 May 2006 8:41 PM
Liz
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:eJQAMhgcGHA.724@TK2MSFTNGP05.phx.gbl...

>> hello!, is there any way that streamreader can be used to read a file
>> published in a web server, ex: "http://localhost/text.txt"
>> or is there any other way of reading such file??
>
> <URL:http://dotnet.mvps.org/dotnet/code/net/#InternetLoadFile>

The code at that URL:

Public Function LoadTextFile(ByVal Url As String) As String
    Dim Request As WebRequest = WebRequest.Create(Url)
    Dim Response As WebResponse = Request.GetResponse()
    Dim Reader As New StreamReader(Response.GetResponseStream())
    LoadTextFile = Reader.ReadToEnd()
    Reader.Close()
    Response.Close()
    Return LoadTextFile
End Function

works for me .... BUT it's really kind of slow (maybe 5-7 seconds to
retrieve a small file (<1K)) .... whereas retrieving it in the browser is
instantaneous ... I've had this problem before in using WebRequest ...  are
there any general suggestions for getting reasonable performance ?  things I
should be looking at ?

TIA

L
Author
8 May 2006 6:23 AM
Cor Ligthert [MVP]
IsMaelf,

In my opinion is the most way to use the
webclient.downloadfile

http://msdn2.microsoft.com/en-us/library/ms144194.aspx

I hope this helps,

Cor

Show quoteHide quote
"Ismaelf" <isma***@gmail.com> schreef in bericht
news:1147023511.888857.144860@j33g2000cwa.googlegroups.com...
> hello!, is there any way that streamreader can be used to read a file
> published in a web server, ex: "http://localhost/text.txt"
> or is there any other way of reading such file??, thanks!
>