Language:

Read files

Language: English
Programming Language: VBScript
Published by: Dennis Pallett [not registered]
Last Update: 5/9/2006
Views: 358

Description

Read files using the FileSystemObject

Code

1 Dim objFSO, objTextStream, strFileName 2 3 Const fsoForReading = 1 4 5 Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 6 7 strFileName = "C:\aspit\test.txt" 8 9 If objFSO.FileExists(strFileName) Then 10 'The file exists, so open it and display it's contents 11 Set objTextStream = objFSO.OpenTextFile(strFileName, fsoForReading) 12 Response.Write objTextStream.ReadAll 13 objTextStream.Close 14 Set objTextStream = Nothing 15 Else 16 'The file doesn't exist 17 Response.Write strFileName & " does not exist." 18 End If 19 20 '"Destroy" the FileSytemObject

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS