ASP FileSystem Object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TOP

    ASP FileSystem Object

    tried to do the following:

    <html>
    <body>
    <p>This is the test</p>
    <%
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
    set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
    set ts = f.OpenAsTextStr eam(ForReading, -2)
    TextStreamTest = ts.ReadLine
    Do While not ts.AtEndOfStrea m
    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\s ite is the root of the
    Site

    Does anybody has an idea ????

    Please help!


    --


    Mit freundlichen Grüßen

    Thomas Pecha


  • Steven Burn

    #2
    Re: ASP FileSystem Object

    Try;

    <%
    Public Const ForReading = 1, ForWriting = 2, ForAppending = 8
    set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
    set f = fso.GetFile(Ser ver.MapPath("/test/testread.txt"))
    set ts = f.OpenAsTextStr eam(ForReading, -2)
    TextStreamTest = ts.ReadLine
    Do While not ts.AtEndOfStrea m
    myText = myText & ts.ReadLine & vbCrLf
    Loop
    response.write( myText)
    %>


    --
    Regards

    Steven Burn
    Ur I.T. Mate Group


    Keeping it FREE!

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


    TOP <non> wrote in message news:ueAViAXxDH A.2092@TK2MSFTN GP09.phx.gbl...[color=blue]
    > tried to do the following:
    >
    > <html>
    > <body>
    > <p>This is the test</p>
    > <%
    > Const ForReading = 1, ForWriting = 2, ForAppending = 8
    > set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
    > set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
    > set ts = f.OpenAsTextStr eam(ForReading, -2)
    > TextStreamTest = ts.ReadLine
    > Do While not ts.AtEndOfStrea m
    > 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.[/color]
    I[color=blue]
    > 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\s ite is the root of[/color]
    the[color=blue]
    > Site
    >
    > Does anybody has an idea ????
    >
    > Please help!
    >
    >
    > --
    >
    >
    > Mit freundlichen Grüßen
    >
    > Thomas Pecha
    >
    >[/color]


    Comment

    • Steven Burn

      #3
      Re: ASP FileSystem Object

      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.CreateOb ject("Scripting .FileSystemObje ct")
      strFile = Server.MapPath( "input_file.txt ")
      Set OutputStream = FileObject.Open TextFile (strFile, ForAppending, True)
      OutputStream.Wr iteLine "Date : " + cstr(Now())
      OutputStream.Cl ose
      Set OutputStream = Nothing
      Set FileObject = Nothing
      %>

      --
      Regards

      Steven Burn
      Ur I.T. Mate Group


      Keeping it FREE!

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


      TOP <non> wrote in message news:ueAViAXxDH A.2092@TK2MSFTN GP09.phx.gbl...[color=blue]
      > tried to do the following:
      >
      > <html>
      > <body>
      > <p>This is the test</p>
      > <%
      > Const ForReading = 1, ForWriting = 2, ForAppending = 8
      > set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
      > set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
      > set ts = f.OpenAsTextStr eam(ForReading, -2)
      > TextStreamTest = ts.ReadLine
      > Do While not ts.AtEndOfStrea m
      > 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.[/color]
      I[color=blue]
      > 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\s ite is the root of[/color]
      the[color=blue]
      > Site
      >
      > Does anybody has an idea ????
      >
      > Please help!
      >
      >
      > --
      >
      >
      > Mit freundlichen Grüßen
      >
      > Thomas Pecha
      >
      >[/color]


      Comment

      • Jeff Cochran

        #4
        Re: ASP FileSystem Object

        On Thu, 18 Dec 2003 15:06:27 +0100, "TOP" <non> wrote:
        [color=blue]
        > tried to do the following:
        >
        ><html>
        ><body>
        ><p>This is the test</p>
        ><%
        >Const ForReading = 1, ForWriting = 2, ForAppending = 8
        >set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
        >set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
        >set ts = f.OpenAsTextStr eam(ForReading, -2)
        >TextStreamTe st = ts.ReadLine
        >Do While not ts.AtEndOfStrea m
        > myText = myText & ts.ReadLine & vbCrLf
        >Loop
        >response.write (myText)
        >%>
        ></body>
        ></html>
        >
        >but it did not work on any machine.[/color]

        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,[color=blue]
        >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\s ite is the root of the
        >Site
        >
        >Does anybody has an idea ????
        >
        >Please help![/color]

        Comment

        • Aaron Bertrand - MVP

          #5
          Re: ASP FileSystem Object

          > Do While not ts.AtEndOfStrea m[color=blue]
          > myText = myText & ts.ReadLine & vbCrLf
          > Loop[/color]

          Ugh. How about

          myText = ts.ReadAll()

          --
          Aaron Bertrand
          SQL Server MVP



          Comment

          • TOP

            #6
            Re: ASP FileSystem Object

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

            set f = fso.GetFile("D: \WWWHosting\sit e\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" <jcochran.nospa m@naplesgov.com > wrote in message
            news:3fe3cac0.6 95834156@msnews .microsoft.com. ..[color=blue]
            > On Thu, 18 Dec 2003 15:06:27 +0100, "TOP" <non> wrote:
            >[color=green]
            > > tried to do the following:
            > >
            > ><html>
            > ><body>
            > ><p>This is the test</p>
            > ><%
            > >Const ForReading = 1, ForWriting = 2, ForAppending = 8
            > >set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
            > >set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
            > >set ts = f.OpenAsTextStr eam(ForReading, -2)
            > >TextStreamTe st = ts.ReadLine
            > >Do While not ts.AtEndOfStrea m
            > > myText = myText & ts.ReadLine & vbCrLf
            > >Loop
            > >response.write (myText)
            > >%>
            > ></body>
            > ></html>
            > >
            > >but it did not work on any machine.[/color]
            >
            > 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,[color=green]
            > >but IIS hangs up, Ihave to kill the IIS process, stop and restart does[/color][/color]
            not[color=blue][color=green]
            > >work. All Userrights are set for the IUSR_Machine UserID on the[/color][/color]
            directory. I[color=blue][color=green]
            > >have no idea why I fail, it worked fine in the past but I guess it was[/color][/color]
            IIS[color=blue][color=green]
            > >4.0 and no .Net Framework. By the way D:\WWWHosting\s ite is the root of[/color][/color]
            the[color=blue][color=green]
            > >Site
            > >
            > >Does anybody has an idea ????
            > >
            > >Please help![/color]
            >[/color]


            Comment

            • TOP

              #7
              Re: ASP FileSystem Object

              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" <aaron@TRASHasp faq.com> wrote in message
              news:%23eD%23r0 XxDHA.2064@TK2M SFTNGP10.phx.gb l...[color=blue][color=green]
              > > Do While not ts.AtEndOfStrea m
              > > myText = myText & ts.ReadLine & vbCrLf
              > > Loop[/color]
              >
              > Ugh. How about
              >
              > myText = ts.ReadAll()
              >
              > --
              > Aaron Bertrand
              > SQL Server MVP
              > http://www.aspfaq.com/
              >
              >[/color]


              Comment

              • Aaron Bertrand - MVP

                #8
                Re: ASP FileSystem Object



                --
                Aaron Bertrand
                SQL Server MVP





                "TOP" <non> wrote in message news:ueAViAXxDH A.2092@TK2MSFTN GP09.phx.gbl...[color=blue]
                > tried to do the following:
                >
                > <html>
                > <body>
                > <p>This is the test</p>
                > <%
                > Const ForReading = 1, ForWriting = 2, ForAppending = 8
                > set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
                > set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
                > set ts = f.OpenAsTextStr eam(ForReading, -2)
                > TextStreamTest = ts.ReadLine
                > Do While not ts.AtEndOfStrea m
                > 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.[/color]
                I[color=blue]
                > 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\s ite is the root of[/color]
                the[color=blue]
                > Site
                >
                > Does anybody has an idea ????
                >
                > Please help!
                >
                >
                > --
                >
                >
                > Mit freundlichen Grüßen
                >
                > Thomas Pecha
                >
                >[/color]


                Comment

                • TOP

                  #9
                  Re: ASP FileSystem Object

                  You are a genius

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

                  Thank you very much!!!



                  "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
                  news:u0ozyKYxDH A.2720@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > http://www.aspfaq.com/2180
                  >
                  > --
                  > Aaron Bertrand
                  > SQL Server MVP
                  > http://www.aspfaq.com/
                  >
                  >
                  >
                  >
                  > "TOP" <non> wrote in message news:ueAViAXxDH A.2092@TK2MSFTN GP09.phx.gbl...[color=green]
                  > > tried to do the following:
                  > >
                  > > <html>
                  > > <body>
                  > > <p>This is the test</p>
                  > > <%
                  > > Const ForReading = 1, ForWriting = 2, ForAppending = 8
                  > > set fso = server.CreateOb ject("Scripting .FileSystemObje ct")
                  > > set f = fso.GetFile("D: \WWWHosting\sit e\test\testread .txt")
                  > > set ts = f.OpenAsTextStr eam(ForReading, -2)
                  > > TextStreamTest = ts.ReadLine
                  > > Do While not ts.AtEndOfStrea m
                  > > 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[/color][/color]
                  1.1,[color=blue][color=green]
                  > > but IIS hangs up, Ihave to kill the IIS process, stop and restart does[/color][/color]
                  not[color=blue][color=green]
                  > > work. All Userrights are set for the IUSR_Machine UserID on the[/color][/color]
                  directory.[color=blue]
                  > I[color=green]
                  > > have no idea why I fail, it worked fine in the past but I guess it was[/color][/color]
                  IIS[color=blue][color=green]
                  > > 4.0 and no .Net Framework. By the way D:\WWWHosting\s ite is the root of[/color]
                  > the[color=green]
                  > > Site
                  > >
                  > > Does anybody has an idea ????
                  > >
                  > > Please help!
                  > >
                  > >
                  > > --
                  > >
                  > >
                  > > Mit freundlichen Grüßen
                  > >
                  > > Thomas Pecha
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Roland Hall

                    #10
                    Re: ASP FileSystem Object

                    "TOP" wrote:[color=blue]
                    > You are a genius
                    >
                    > That was it !!!!!!!!!!!!!!! !!
                    >
                    > Thank you very much!!![/color]

                    another happy customer... (O:=


                    Comment

                    Working...