|
 |
asp_web_howto thread: Reading Text using "ReadAll Method"
Message #1 by gabriele@g... on Tue, 18 Sep 2001 21:49:14
|
|
Hi guys!
I am trying to read the content of a text file.
I am using this script (which is in the Microsoft VBscript 5.5
documentation):
<%@ LANGUAGE="VBSCRIPT" %>
Function ReadAllTextFile
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt", ForWriting,
True)
f.Write "Hello world!"
Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt", ForReading)
ReadAllTextFile = f.ReadAll
End Function
%>
This script doesn't work in both reading and writing.
I have tried to read from a file containing a text to check the reading
part. Nothing!
THanks a lot!
Gabriele
Message #2 by "phil griffiths" <pgtips@m...> on Wed, 19 Sep 2001 09:26:39
|
|
It works fine for me (as long as you add an opening ASP tag <% before
Function).
How are you calling the function? Lets see all of your code.
Phil
> Hi guys!
>
> I am trying to read the content of a text file.
>
> I am using this script (which is in the Microsoft VBscript 5.5
> documentation):
>
> <%@ LANGUAGE="VBSCRIPT" %>
> Function ReadAllTextFile
> Const ForReading = 1, ForWriting = 2
> Dim fso, f
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt",
ForWriting,
> True)
> f.Write "Hello world!"
> Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt",
ForReading)
> ReadAllTextFile = f.ReadAll
>
> End Function
> %>
>
> This script doesn't work in both reading and writing.
> I have tried to read from a file containing a text to check the reading
> part. Nothing!
>
> THanks a lot!
> Gabriele
Message #3 by patrick.frenette@s... on Thu, 20 Sep 2001 12:50:33
|
|
Close your file before reopening it
> Hi guys!
>
> I am trying to read the content of a text file.
>
> I am using this script (which is in the Microsoft VBscript 5.5
> documentation):
>
> <%@ LANGUAGE="VBSCRIPT" %>
> Function ReadAllTextFile
> Const ForReading = 1, ForWriting = 2
> Dim fso, f
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt",
ForWriting,
> True)
> f.Write "Hello world!"
> Set f = fso.OpenTextFile("C:\Inetpub\wwwroot\testfile.txt",
ForReading)
> ReadAllTextFile = f.ReadAll
>
> End Function
> %>
>
> This script doesn't work in both reading and writing.
> I have tried to read from a file containing a text to check the reading
> part. Nothing!
>
> THanks a lot!
> Gabriele
|
|
 |