-
Can anyone tell me how to very very very simply open a file from the web server.. ie: openning "myfile.txt" when a HTML file is viewed.
<HTML>
<HEAD><TITLE>My File</TITLE></HEAD>
<H1><B>ASP Script</B></H1>
<BODY>
<BR>
<HR>
<% code to open a file %>
<BR>
<% Next %>
<HR>
</BODY>
</HTML>
Many Thanks
-
format
What if i wanted to format the output somewhat?
Regards Gary
-
Try using the Open statement, as in a normal VB program.
-
Use CSS.
Or you could use <style></style> tags before and after you open the text file. Just insert the style sheet attributes in the first tag.
-
SSI doesn't care about formatting, it just expands it in-place, so using CSS like that would work. If you want to format the individual parts of the file, then you'd have to open it yourself using ASP. My SSI method was THE simplest way imaginable...
-
use VB
I would like to use VB to open a file and display it line by line wrapped in ASP tags
<% vb code %>
Can you show me how this is done to understand the declarations needed for the web.?
Many Thanks
-
You use the FileSystem Object to open and read files.
Here's some sample code using the object:
http://msdn.microsoft.com/scripting/...gfsosample.htm
-
whaaaaooh
**** me.. surely i dont need all that?
-
To read the file you should only need the following:
Code:
Function GetLyrics(FSO)
Dim TextStream
Dim S
Dim File
' There are several ways to open a text file, and several
' ways to read the data out of a file. Here's two ways
' to do each:
Set TextStream = FSO.OpenTextFile(TestFilePath & "\Beatles\OctopusGarden.txt", OpenFileForReading)
S = TextStream.ReadAll & NewLine & NewLine
TextStream.Close
Set File = FSO.GetFile(TestFilePath & "\Beatles\BathroomWindow.txt")
Set TextStream = File.OpenAsTextStream(OpenFileForReading)
Do While Not TextStream.AtEndOfStream
S = S & TextStream.ReadLine & NewLine
Loop
TextStream.Close
GetLyrics = S
End Function
Make sure you declare the constants (OpenFileForReading, etc) or if you don't want to declare them just use the constant's value in the method calls.
[Edited by ttingen on 08-18-2000 at 11:28 AM]
-
WEB PAGE