Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: COM/DCOM/COM+
Expertise: Beginner
Jul 19, 1999

Accessing Text File Data From ASP Pages

Question:
Can I retrieve data from a text file instead of querying an Access database?

Answer:
Yes, you can access a text file from an ASP page. Use the FileSystemObject COM component that ships with IIS.

First, create a FileSystemObject object.

   Dim fs, f, strOneLine
   Set fs = CreateObject("Scripting.FileSystemObject")
Next, create a TextStream Object out of the FileSysemObject.
   Set f = fs.OpenTextFile("c:\testfile.txt", 1,0)
   ' -- in above code,
   ' -- 1 = for reading
   ' -- 0 = TriStateFalse
Read lines from the TextStream Object. Use the AtEndOfStream property to make sure you are not at end of file.
   Do While f.AtEndOfStream <> True    
      strOneLine = F.ReadLine    
      ' -- do something with your line
   Loop
Finally, close all your objects.
   F.Close
   Set f = Nothing
   Set fs = Nothing
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date