ASP FileSystem Object

Discussion in 'ASP General' started by TOP, Dec 18, 2003.

  1. TOP

    TOP Guest

    tried to do the following:

    <html>
    <body>
    <p>This is the test</p>
    <%
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    set fso = server.CreateObject("Scripting.FileSystemObject")
    set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    set ts = f.OpenAsTextStream(ForReading, -2)
    TextStreamTest = ts.ReadLine
    Do While not ts.AtEndOfStream
    myText = myText & ts.ReadLine & vbCrLf
    Loop
    response.write(myText)
    %>
    </body>
    </html>

    but it did not work on any machine. - I have IIS 5.1, .Net Framework 1.1,
    but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
    work. All Userrights are set for the IUSR_Machine UserID on the directory. I
    have no idea why I fail, it worked fine in the past but I guess it was IIS
    4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of the
    Site

    Does anybody has an idea ????

    Please help!


    --


    Mit freundlichen Grüßen

    Thomas Pecha
     
    TOP, Dec 18, 2003
    #1
    1. Advertising

  2. TOP

    Steven Burn Guest

    Try;

    <%
    Public Const ForReading = 1, ForWriting = 2, ForAppending = 8
    set fso = server.CreateObject("Scripting.FileSystemObject")
    set f = fso.GetFile(Server.MapPath("/test/testread.txt"))
    set ts = f.OpenAsTextStream(ForReading, -2)
    TextStreamTest = ts.ReadLine
    Do While not ts.AtEndOfStream
    myText = myText & ts.ReadLine & vbCrLf
    Loop
    response.write(myText)
    %>


    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    Disclaimer:
    I know I'm probably wrong, I just like taking part ;o)


    TOP <non> wrote in message news:...
    > tried to do the following:
    >
    > <html>
    > <body>
    > <p>This is the test</p>
    > <%
    > Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > set fso = server.CreateObject("Scripting.FileSystemObject")
    > set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    > set ts = f.OpenAsTextStream(ForReading, -2)
    > TextStreamTest = ts.ReadLine
    > Do While not ts.AtEndOfStream
    > myText = myText & ts.ReadLine & vbCrLf
    > Loop
    > response.write(myText)
    > %>
    > </body>
    > </html>
    >
    > but it did not work on any machine. - I have IIS 5.1, .Net Framework 1.1,
    > but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
    > work. All Userrights are set for the IUSR_Machine UserID on the directory.

    I
    > have no idea why I fail, it worked fine in the past but I guess it was IIS
    > 4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of

    the
    > Site
    >
    > Does anybody has an idea ????
    >
    > Please help!
    >
    >
    > --
    >
    >
    > Mit freundlichen Grüßen
    >
    > Thomas Pecha
    >
    >
     
    Steven Burn, Dec 18, 2003
    #2
    1. Advertising

  3. TOP

    Steven Burn Guest

    Below is the code I wrote for one of my clients site's........, might want
    to verify it against yours?

    <%
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
    strFile = Server.MapPath("input_file.txt")
    Set OutputStream = FileObject.OpenTextFile (strFile, ForAppending, True)
    OutputStream.WriteLine "Date : " + cstr(Now())
    OutputStream.Close
    Set OutputStream = Nothing
    Set FileObject = Nothing
    %>

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    Disclaimer:
    I know I'm probably wrong, I just like taking part ;o)


    TOP <non> wrote in message news:...
    > tried to do the following:
    >
    > <html>
    > <body>
    > <p>This is the test</p>
    > <%
    > Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > set fso = server.CreateObject("Scripting.FileSystemObject")
    > set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    > set ts = f.OpenAsTextStream(ForReading, -2)
    > TextStreamTest = ts.ReadLine
    > Do While not ts.AtEndOfStream
    > myText = myText & ts.ReadLine & vbCrLf
    > Loop
    > response.write(myText)
    > %>
    > </body>
    > </html>
    >
    > but it did not work on any machine. - I have IIS 5.1, .Net Framework 1.1,
    > but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
    > work. All Userrights are set for the IUSR_Machine UserID on the directory.

    I
    > have no idea why I fail, it worked fine in the past but I guess it was IIS
    > 4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of

    the
    > Site
    >
    > Does anybody has an idea ????
    >
    > Please help!
    >
    >
    > --
    >
    >
    > Mit freundlichen Grüßen
    >
    > Thomas Pecha
    >
    >
     
    Steven Burn, Dec 18, 2003
    #3
  4. > Do While not ts.AtEndOfStream
    > myText = myText & ts.ReadLine & vbCrLf
    > Loop


    Ugh. How about

    myText = ts.ReadAll()

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/
     
    Aaron Bertrand - MVP, Dec 18, 2003
    #4
  5. TOP

    Jeff Cochran Guest

    On Thu, 18 Dec 2003 15:06:27 +0100, "TOP" <non> wrote:

    > tried to do the following:
    >
    ><html>
    ><body>
    ><p>This is the test</p>
    ><%
    >Const ForReading = 1, ForWriting = 2, ForAppending = 8
    >set fso = server.CreateObject("Scripting.FileSystemObject")
    >set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    >set ts = f.OpenAsTextStream(ForReading, -2)
    >TextStreamTest = ts.ReadLine
    >Do While not ts.AtEndOfStream
    > myText = myText & ts.ReadLine & vbCrLf
    >Loop
    >response.write(myText)
    >%>
    ></body>
    ></html>
    >
    >but it did not work on any machine.


    Did not work? How do you know? What *did* happen? Is the file where
    you think it is?

    Jeff


    - I have IIS 5.1, .Net Framework 1.1,
    >but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
    >work. All Userrights are set for the IUSR_Machine UserID on the directory. I
    >have no idea why I fail, it worked fine in the past but I guess it was IIS
    >4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of the
    >Site
    >
    >Does anybody has an idea ????
    >
    >Please help!
     
    Jeff Cochran, Dec 18, 2003
    #5
  6. TOP

    TOP Guest

    I logged into a mdb therfore I know that it does work until

    set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")

    That means creating the fso is fine then it stopps and IIS hangs up.

    To all the guys trying to help with coding: I all tried this already -
    sorry - it also works with server.mappath the samme way, means the path is
    correct.


    "Jeff Cochran" <> wrote in message
    news:...
    > On Thu, 18 Dec 2003 15:06:27 +0100, "TOP" <non> wrote:
    >
    > > tried to do the following:
    > >
    > ><html>
    > ><body>
    > ><p>This is the test</p>
    > ><%
    > >Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > >set fso = server.CreateObject("Scripting.FileSystemObject")
    > >set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    > >set ts = f.OpenAsTextStream(ForReading, -2)
    > >TextStreamTest = ts.ReadLine
    > >Do While not ts.AtEndOfStream
    > > myText = myText & ts.ReadLine & vbCrLf
    > >Loop
    > >response.write(myText)
    > >%>
    > ></body>
    > ></html>
    > >
    > >but it did not work on any machine.

    >
    > Did not work? How do you know? What *did* happen? Is the file where
    > you think it is?
    >
    > Jeff
    >
    >
    > - I have IIS 5.1, .Net Framework 1.1,
    > >but IIS hangs up, Ihave to kill the IIS process, stop and restart does

    not
    > >work. All Userrights are set for the IUSR_Machine UserID on the

    directory. I
    > >have no idea why I fail, it worked fine in the past but I guess it was

    IIS
    > >4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of

    the
    > >Site
    > >
    > >Does anybody has an idea ????
    > >
    > >Please help!

    >
     
    TOP, Dec 18, 2003
    #6
  7. TOP

    TOP Guest

    stays the same

    it stops after creating the fso, I know that becaus I am logging int a mdb
    (which works fine)


    "Aaron Bertrand - MVP" <> wrote in message
    news:%23eD%...
    > > Do While not ts.AtEndOfStream
    > > myText = myText & ts.ReadLine & vbCrLf
    > > Loop

    >
    > Ugh. How about
    >
    > myText = ts.ReadAll()
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >
    >
     
    TOP, Dec 18, 2003
    #7
  8. http://www.aspfaq.com/2180

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/




    "TOP" <non> wrote in message news:...
    > tried to do the following:
    >
    > <html>
    > <body>
    > <p>This is the test</p>
    > <%
    > Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > set fso = server.CreateObject("Scripting.FileSystemObject")
    > set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    > set ts = f.OpenAsTextStream(ForReading, -2)
    > TextStreamTest = ts.ReadLine
    > Do While not ts.AtEndOfStream
    > myText = myText & ts.ReadLine & vbCrLf
    > Loop
    > response.write(myText)
    > %>
    > </body>
    > </html>
    >
    > but it did not work on any machine. - I have IIS 5.1, .Net Framework 1.1,
    > but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
    > work. All Userrights are set for the IUSR_Machine UserID on the directory.

    I
    > have no idea why I fail, it worked fine in the past but I guess it was IIS
    > 4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of

    the
    > Site
    >
    > Does anybody has an idea ????
    >
    > Please help!
    >
    >
    > --
    >
    >
    > Mit freundlichen Grüßen
    >
    > Thomas Pecha
    >
    >
     
    Aaron Bertrand - MVP, Dec 18, 2003
    #8
  9. TOP

    TOP Guest

    You are a genius

    That was it !!!!!!!!!!!!!!!!!

    Thank you very much!!!



    "Aaron Bertrand - MVP" <> wrote in message
    news:...
    > http://www.aspfaq.com/2180
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >
    >
    >
    >
    > "TOP" <non> wrote in message news:...
    > > tried to do the following:
    > >
    > > <html>
    > > <body>
    > > <p>This is the test</p>
    > > <%
    > > Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > > set fso = server.CreateObject("Scripting.FileSystemObject")
    > > set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
    > > set ts = f.OpenAsTextStream(ForReading, -2)
    > > TextStreamTest = ts.ReadLine
    > > Do While not ts.AtEndOfStream
    > > myText = myText & ts.ReadLine & vbCrLf
    > > Loop
    > > response.write(myText)
    > > %>
    > > </body>
    > > </html>
    > >
    > > but it did not work on any machine. - I have IIS 5.1, .Net Framework

    1.1,
    > > but IIS hangs up, Ihave to kill the IIS process, stop and restart does

    not
    > > work. All Userrights are set for the IUSR_Machine UserID on the

    directory.
    > I
    > > have no idea why I fail, it worked fine in the past but I guess it was

    IIS
    > > 4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of

    > the
    > > Site
    > >
    > > Does anybody has an idea ????
    > >
    > > Please help!
    > >
    > >
    > > --
    > >
    > >
    > > Mit freundlichen Grüßen
    > >
    > > Thomas Pecha
    > >
    > >

    >
    >
     
    TOP, Dec 18, 2003
    #9
  10. TOP

    Roland Hall Guest

    "TOP" wrote:
    > You are a genius
    >
    > That was it !!!!!!!!!!!!!!!!!
    >
    > Thank you very much!!!


    another happy customer... (O:=
     
    Roland Hall, Dec 19, 2003
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Qing
    Replies:
    0
    Views:
    1,616
    Brian Qing
    Apr 17, 2004
  2. Daz
    Replies:
    8
    Views:
    435
    Jonathan Mcdougall
    May 13, 2006
  3. Lise
    Replies:
    0
    Views:
    118
  4. stuart

    Filesystem Object and IIS6

    stuart, Jul 29, 2004, in forum: ASP General
    Replies:
    2
    Views:
    157
    Stuart Cochrane
    Jul 30, 2004
  5. Raj Babar

    FileSystem Object

    Raj Babar, Aug 29, 2003, in forum: Javascript
    Replies:
    1
    Views:
    102
    Svend Tofte
    Aug 29, 2003
Loading...

Share This Page