Click to See Complete Forum and Search --> : open online text file
vdjan
March 1st, 2007, 04:37 AM
Hi,
I would like to open a text file and read it line per line.
The file is however online, like http://www.mysite.com/thisfile.txt
How do I do this using asp.net with vbscript?
thx,
Jan
vdjan
March 5th, 2007, 02:58 AM
Hmm.. is this so difficult? :s
I would really appreciate if someone could helpme out here.
I'm trying to check if our ftp servers have downloaded the latest virus engines. Therefor I need to compare versionnbr in an ini file with a versionnbr in another ini file. The first ini file is available from the suppliers http site, so that's why I would like to know how I could read the contents of the file in my aspx page.
cykophysh
March 5th, 2007, 10:07 AM
Check out this article
http://threenineconsulting.com/forum/blogs/cykophysh/archive/2006/11/24/Write-and-Read-a-Text-File-In-C_2300_.aspx
You may need to use the HttpRequest and HttpRespond object to get the Text file first. I am not sure if you may even be able to try opening the text file via Http , give it a try
vdjan
March 7th, 2007, 10:01 AM
Thanks for the reply.
The article is however about local files, I tried using this method for the 'online' files, but it doesn't work. :(
Charu0306
March 9th, 2007, 04:59 AM
You'll have to download the file and parse it locally in some temp dir. and then delete ti after use.
Charu0306
March 9th, 2007, 05:03 AM
Example:
Dim root As String = "C:\temp\"
Dim filepath As String = Request.Params("file")
If Not filepath Is Nothing Then
If File.Exists(filepath) And filepath.StartsWith(root) Then
Dim filename As String = Path.GetFileName(filepath)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", _
"attachment; filename=""" & filename & """")
Response.Flush()
Response.WriteFile(filepath)
End If
End If
The request.params argument contains your URL with the file name included in it. You just need to permissions to access that file.
vdjan
March 12th, 2007, 04:44 AM
Doesn't do the trick... :(
Why this => If File.Exists(filepath) And filepath.StartsWith(root) Then
filepath is my URL, right?
How could it start with the local path?
If I could read the content of the file I would be more then happy.
ex: "http://www.sybari.com/scan_engine_updates/intel/cairis/update.ini"
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.