
September 19th, 2000, 07:22 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
<i><b>Originally posted by : Richard (richard@trinet.co.uk)</b></i><br />The following function will return the contents of a file on your web-server. Pass it the name of the file relative to the current document. For example, if you documents are in a folder called 'Documents', call:<br /> Response.Write _<br /> GetHTMLFile("Documents/test.html")<br />to output the contents of an HTML file called test. If the documents contain plain text, you may want to use:<br /> Response.Write Server.HTMLEncode _<br /> (GetHTMLFile("Documents/test.txt"))<br />to ensure it displays properly.<br /><br /><br />Function GetHTMLFile(strFileName)<br />Dim fso, file, FName<br />On Error Resume Next<br /> FName = Server.MapPath(strFileName)<br /> Set fso = Server.CreateObject _<br /> ("Scripting.FileSystemObject")<br /><br /> If Not(fso Is Nothing) Then<br /> If fso.FileExists(FName) Then<br /> Set file=fso.OpenTextFile(FName,1)<br /> GetHTMLFile = Trim(file.readAll())<br /> Else<br /> GetHTMLFile = _<br /> "<H3>File not found - " & _<br /> FName & "</H3>" & vbCrLf<br /> End If<br /> Set fso = Nothing<br /> Else<br /> GetHTMLFile="<H3>Unable to find file - " _<br /> & err.description & "</H3>"<br /> End If<br />End Function<br />
|