Can someone please confirm this behavior?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Bertrand - MVP

    Can someone please confirm this behavior?

    Based on a complaint that one of my articles just links to the MS
    documentation, I'm writing a tutorial on FileSystemObjec t. However I'm
    currently getting stalled by this bug.

    Environment: Windows Server 2003, IIS 6.0, VBScript 5.6, all windows and IE
    update patches (to my knowledge).

    From
    msdn.microsoft. com/library/en-us/script56/html/jsmthcreatetext file.asp

    The FileSystemObjec t doc for CreateTextFile states for the overwrite
    parameter:

    "Optional.
    Boolean value that indicates whether you can overwrite an existing file. The
    value is true if the file can be overwritten, false if it can't be
    overwritten. If omitted, existing files are not overwritten. "

    I believe "If omitted, existing files are not overwritten" is an inaccurate
    statement. The following code definitely overwrites the file.

    <%
    set fso = CreateObject("S cripting.FileSy stemObject")

    set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
    fs.writeline("f oo!")
    fs.close: set fs = nothing

    set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
    fs.writeline("o verwrite!")
    fs.close: set fs = nothing

    fso.close: set fso = nothing
    %>

    According to the doc, calling CreateTextFile( filename) should be equivalent
    to calling CreateTextFile( filename, false). However when I do the former,
    it overwrites the file (try it out, and examine foo.txt). When I do the
    latter, I get the following error:

    Microsoft VBScript runtime error '800a003a'
    File already exists

    So, (a) is the documentation incorrect, (b) is FileSystemObjec t behaving
    incorrectly, (c) are the docs I'm looking at outdated, or (d) is there
    potentially some configuration issue in my environment that makes this
    script misbehave (e.g. does it work right for you)?

    I just want to make sure that if the behavior is correct and the docs are
    wrong, or if the docs or correct and the behavior is wrong, I convey the
    correct location of the bug. :-)

    Thanks in advance.
    --
    Aaron Bertrand
    SQL Server MVP
    This is a default index page for a new domain.



  • Aaron Bertrand - MVP

    #2
    Re: Can someone please confirm this behavior?

    (BTW - Same behavior on XP Pro.)


    Comment

    • Ray at

      #3
      Re: Can someone please confirm this behavior?


      "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
      news:e#aCBlQxDH A.1596@TK2MSFTN GP10.phx.gbl...[color=blue]
      >
      > I believe "If omitted, existing files are not overwritten" is an[/color]
      inaccurate[color=blue]
      > statement. The following code definitely overwrites the file.[/color]

      Yep, same thing here. With no argument passed, file is overwritten. With
      False passed, I get the "file already exists" as expected, and with True, it
      behaves as though it was omitted.

      [color=blue]
      >
      > So, (a) is the documentation incorrect, (b) is FileSystemObjec t behaving
      > incorrectly, (c) are the docs I'm looking at outdated, or (d) is there
      > potentially some configuration issue in my environment that makes this
      > script misbehave (e.g. does it work right for you)?[/color]

      I'll pick a.


      I tried this on W2K Server with WSH5.6, btw.

      Ray at home


      Comment

      • Ray at

        #4
        Re: Can someone please confirm this behavior?


        "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
        news:e#aCBlQxDH A.1596@TK2MSFTN GP10.phx.gbl...[color=blue]
        > <%
        > fso.close: set fso = nothing
        > %>
        >[/color]

        p.s. fso.close? :P

        Ray at home


        Comment

        • Chris Hohmann

          #5
          Re: Can someone please confirm this behavior?

          "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
          news:e%23aCBlQx DHA.1596@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > Based on a complaint that one of my articles just links to the MS
          > documentation, I'm writing a tutorial on FileSystemObjec t. However[/color]
          I'm[color=blue]
          > currently getting stalled by this bug.
          >
          > Environment: Windows Server 2003, IIS 6.0, VBScript 5.6, all windows[/color]
          and IE[color=blue]
          > update patches (to my knowledge).
          >
          > From
          > msdn.microsoft. com/library/en-us/script56/html/jsmthcreatetext file.asp
          >
          > The FileSystemObjec t doc for CreateTextFile states for the overwrite
          > parameter:
          >
          > "Optional.
          > Boolean value that indicates whether you can overwrite an existing[/color]
          file. The[color=blue]
          > value is true if the file can be overwritten, false if it can't be
          > overwritten. If omitted, existing files are not overwritten. "
          >
          > I believe "If omitted, existing files are not overwritten" is an[/color]
          inaccurate[color=blue]
          > statement. The following code definitely overwrites the file.
          >
          > <%
          > set fso = CreateObject("S cripting.FileSy stemObject")
          >
          > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
          > fs.writeline("f oo!")
          > fs.close: set fs = nothing
          >
          > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
          > fs.writeline("o verwrite!")
          > fs.close: set fs = nothing
          >
          > fso.close: set fso = nothing
          > %>
          >
          > According to the doc, calling CreateTextFile( filename) should be[/color]
          equivalent[color=blue]
          > to calling CreateTextFile( filename, false). However when I do the[/color]
          former,[color=blue]
          > it overwrites the file (try it out, and examine foo.txt). When I do[/color]
          the[color=blue]
          > latter, I get the following error:
          >
          > Microsoft VBScript runtime error '800a003a'
          > File already exists
          >
          > So, (a) is the documentation incorrect, (b) is FileSystemObjec t[/color]
          behaving[color=blue]
          > incorrectly, (c) are the docs I'm looking at outdated, or (d) is there
          > potentially some configuration issue in my environment that makes this
          > script misbehave (e.g. does it work right for you)?
          >
          > I just want to make sure that if the behavior is correct and the docs[/color]
          are[color=blue]
          > wrong, or if the docs or correct and the behavior is wrong, I convey[/color]
          the[color=blue]
          > correct location of the bug. :-)
          >
          > Thanks in advance.
          > --
          > Aaron Bertrand
          > SQL Server MVP
          > http://www.aspfaq.com/[/color]

          Same here.

          Notes:
          1. Here's someone else who encountered the same thing. He didn't get an
          answer either.


          2. I declared but did not initialize a variable "a" and passed that as
          the overwrite parameter and it behaved as advertised in the
          documentation (i.e.. File exists error was thrown). Perhaps the
          CreateTextFile method is dealing with the absence of the argument in a
          non-standard way. Pure conjecture on my part.

          -Chris Hohmann



          Comment

          • Sylvain Lafontaine

            #6
            Re: Can someone please confirm this behavior?

            A quick look at the Microsoft Scripting Runtime (scrrun.dll) with the Object
            Browser show that the second parameter is True by default:
            Function CreateTextFile( ByVal FileName As String, [ByVal Overwrite As
            Boolean = True], [ByVal Unicode As Boolean = False]) As ITextStream

            Member of Scripting.FileS ystemObject

            Create a file as a TextStream

            From this, we can say that the documentation is clearly wrong. This is on
            XP with VBScript 5.6.

            S. L.


            "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
            news:e%23aCBlQx DHA.1596@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > Based on a complaint that one of my articles just links to the MS
            > documentation, I'm writing a tutorial on FileSystemObjec t. However I'm
            > currently getting stalled by this bug.
            >
            > Environment: Windows Server 2003, IIS 6.0, VBScript 5.6, all windows and[/color]
            IE[color=blue]
            > update patches (to my knowledge).
            >
            > From
            > msdn.microsoft. com/library/en-us/script56/html/jsmthcreatetext file.asp
            >
            > The FileSystemObjec t doc for CreateTextFile states for the overwrite
            > parameter:
            >
            > "Optional.
            > Boolean value that indicates whether you can overwrite an existing file.[/color]
            The[color=blue]
            > value is true if the file can be overwritten, false if it can't be
            > overwritten. If omitted, existing files are not overwritten. "
            >
            > I believe "If omitted, existing files are not overwritten" is an[/color]
            inaccurate[color=blue]
            > statement. The following code definitely overwrites the file.
            >
            > <%
            > set fso = CreateObject("S cripting.FileSy stemObject")
            >
            > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
            > fs.writeline("f oo!")
            > fs.close: set fs = nothing
            >
            > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
            > fs.writeline("o verwrite!")
            > fs.close: set fs = nothing
            >
            > fso.close: set fso = nothing
            > %>
            >
            > According to the doc, calling CreateTextFile( filename) should be[/color]
            equivalent[color=blue]
            > to calling CreateTextFile( filename, false). However when I do the former,
            > it overwrites the file (try it out, and examine foo.txt). When I do the
            > latter, I get the following error:
            >
            > Microsoft VBScript runtime error '800a003a'
            > File already exists
            >
            > So, (a) is the documentation incorrect, (b) is FileSystemObjec t behaving
            > incorrectly, (c) are the docs I'm looking at outdated, or (d) is there
            > potentially some configuration issue in my environment that makes this
            > script misbehave (e.g. does it work right for you)?
            >
            > I just want to make sure that if the behavior is correct and the docs are
            > wrong, or if the docs or correct and the behavior is wrong, I convey the
            > correct location of the bug. :-)
            >
            > Thanks in advance.
            > --
            > Aaron Bertrand
            > SQL Server MVP
            > http://www.aspfaq.com/
            >
            >[/color]


            Comment

            • Aaron Bertrand - MVP

              #7
              Re: Can someone please confirm this behavior?

              Sory, bad cut & paste, I guess. :-\

              --
              Aaron Bertrand
              SQL Server MVP
              This is a default index page for a new domain.


              [color=blue]
              >
              > p.s. fso.close? :P
              >
              > Ray at home
              >
              >[/color]


              Comment

              • Mark Schupp

                #8
                Re: Can someone please confirm this behavior?

                "Those who live by the optional parameter, die by the optional parameter"
                (slightly paraphrased).

                --
                Mark Schupp
                Head of Development
                Integrity eLearning
                Advancing limitless knowledge and continual growth to create confident problem solvers, one course at a time.



                "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                wrote in message news:%23pgwR1Sx DHA.1060@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                > A quick look at the Microsoft Scripting Runtime (scrrun.dll) with the[/color]
                Object[color=blue]
                > Browser show that the second parameter is True by default:
                > Function CreateTextFile( ByVal FileName As String, [ByVal Overwrite As
                > Boolean = True], [ByVal Unicode As Boolean = False]) As ITextStream
                >
                > Member of Scripting.FileS ystemObject
                >
                > Create a file as a TextStream
                >
                > From this, we can say that the documentation is clearly wrong. This is on
                > XP with VBScript 5.6.
                >
                > S. L.
                >
                >
                > "Aaron Bertrand - MVP" <aaron@TRASHasp faq.com> wrote in message
                > news:e%23aCBlQx DHA.1596@TK2MSF TNGP10.phx.gbl. ..[color=green]
                > > Based on a complaint that one of my articles just links to the MS
                > > documentation, I'm writing a tutorial on FileSystemObjec t. However I'm
                > > currently getting stalled by this bug.
                > >
                > > Environment: Windows Server 2003, IIS 6.0, VBScript 5.6, all windows and[/color]
                > IE[color=green]
                > > update patches (to my knowledge).
                > >
                > > From
                > > msdn.microsoft. com/library/en-us/script56/html/jsmthcreatetext file.asp
                > >
                > > The FileSystemObjec t doc for CreateTextFile states for the overwrite
                > > parameter:
                > >
                > > "Optional.
                > > Boolean value that indicates whether you can overwrite an existing file.[/color]
                > The[color=green]
                > > value is true if the file can be overwritten, false if it can't be
                > > overwritten. If omitted, existing files are not overwritten. "
                > >
                > > I believe "If omitted, existing files are not overwritten" is an[/color]
                > inaccurate[color=green]
                > > statement. The following code definitely overwrites the file.
                > >
                > > <%
                > > set fso = CreateObject("S cripting.FileSy stemObject")
                > >
                > > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
                > > fs.writeline("f oo!")
                > > fs.close: set fs = nothing
                > >
                > > set fs = fso.createTextF ile(Server.MapP ath("foo.txt"))
                > > fs.writeline("o verwrite!")
                > > fs.close: set fs = nothing
                > >
                > > fso.close: set fso = nothing
                > > %>
                > >
                > > According to the doc, calling CreateTextFile( filename) should be[/color]
                > equivalent[color=green]
                > > to calling CreateTextFile( filename, false). However when I do the[/color][/color]
                former,[color=blue][color=green]
                > > it overwrites the file (try it out, and examine foo.txt). When I do the
                > > latter, I get the following error:
                > >
                > > Microsoft VBScript runtime error '800a003a'
                > > File already exists
                > >
                > > So, (a) is the documentation incorrect, (b) is FileSystemObjec t behaving
                > > incorrectly, (c) are the docs I'm looking at outdated, or (d) is there
                > > potentially some configuration issue in my environment that makes this
                > > script misbehave (e.g. does it work right for you)?
                > >
                > > I just want to make sure that if the behavior is correct and the docs[/color][/color]
                are[color=blue][color=green]
                > > wrong, or if the docs or correct and the behavior is wrong, I convey the
                > > correct location of the bug. :-)
                > >
                > > Thanks in advance.
                > > --
                > > Aaron Bertrand
                > > SQL Server MVP
                > > http://www.aspfaq.com/
                > >
                > >[/color]
                >
                >[/color]


                Comment

                Working...