473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 FileSystemObject. 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/jsmthcreatetextfile.asp

The FileSystemObject 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("Scripting.FileSystemObject")

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("foo!")
fs.close: set fs = nothing

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("overwrite!")
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 FileSystemObject 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/
Jul 19 '05 #1
7 3977
(BTW - Same behavior on XP Pro.)
Jul 19 '05 #2

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:e#**************@TK2MSFTNGP10.phx.gbl...

I believe "If omitted, existing files are not overwritten" is an inaccurate statement. The following code definitely overwrites the file.
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.


So, (a) is the documentation incorrect, (b) is FileSystemObject 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'll pick a.
I tried this on W2K Server with WSH5.6, btw.

Ray at home
Jul 19 '05 #3

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:e#**************@TK2MSFTNGP10.phx.gbl...
<%
fso.close: set fso = nothing
%>


p.s. fso.close? :P

Ray at home
Jul 19 '05 #4
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Based on a complaint that one of my articles just links to the MS
documentation, I'm writing a tutorial on FileSystemObject. 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/jsmthcreatetextfile.asp

The FileSystemObject 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("Scripting.FileSystemObject")

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("foo!")
fs.close: set fs = nothing

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("overwrite!")
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 FileSystemObject 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/


Same here.

Notes:
1. Here's someone else who encountered the same thing. He didn't get an
answer either.
http://groups.google.com/groups?thre...3B%40hydro.com

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

Jul 19 '05 #5
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.FileSystemObject

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" <aa***@TRASHaspfaq.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Based on a complaint that one of my articles just links to the MS
documentation, I'm writing a tutorial on FileSystemObject. 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/jsmthcreatetextfile.asp

The FileSystemObject 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("Scripting.FileSystemObject")

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("foo!")
fs.close: set fs = nothing

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("overwrite!")
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 FileSystemObject 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/

Jul 19 '05 #6
Sory, bad cut & paste, I guess. :-\

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


p.s. fso.close? :P

Ray at home

Jul 19 '05 #7
"Those who live by the optional parameter, die by the optional parameter"
(slightly paraphrased).

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
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.FileSystemObject

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" <aa***@TRASHaspfaq.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Based on a complaint that one of my articles just links to the MS
documentation, I'm writing a tutorial on FileSystemObject. 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/jsmthcreatetextfile.asp

The FileSystemObject 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("Scripting.FileSystemObject")

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("foo!")
fs.close: set fs = nothing

set fs = fso.createTextFile(Server.MapPath("foo.txt"))
fs.writeline("overwrite!")
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 FileSystemObject 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/


Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

87
9494
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
20
3728
by: nicolas.riesch | last post by:
I try to understand strict aliasing rules that are in the C Standard. As gcc applies these rules by default, I just want to be sure to understand fully this issue. For questions (1), (2) and...
7
1691
by: Tigger | last post by:
Dear Experts, I am working on ASP.NET. I have got a problem related to the usage of Javascript in ASP.NET. Please help. The story is the following: 1) I am developing an ASP.NET application. I...
4
2445
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
2
1168
by: Ike | last post by:
Can someone ple4ase confirm my understanding of this line of html/javascript code below?If, when the submit button is pressed, the javascript function checkdate() returns true, the form's action...
5
13033
by: robert | last post by:
I have a dropdownlist with the autopostback set to true. I want the user to be confirm whether they do indeed want to change the value, which on post back fires a server side event...
6
962
by: pigeonrandle | last post by:
Hi, I have been trying to find an answer, even a hint, but despite posting the following question on various forums i haven't even had a single reply for nearly two weeks :o(. "Why do...
1
2023
by: silentscreams22 | last post by:
I need this converted. <marquee behavior="scroll" direction="down" scrollamount="3" style="position:absolute; left:110px; top:150px; width:16px; height:483px; z-index:1;"><span...
5
11642
by: GiJeet | last post by:
Hello, I'm trying to figure this code out. <input type="submit" onclick="if(!confirm('Are you sure?') return false; "... /> I know that if you return false in an event like this onclick it...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.