473,549 Members | 2,847 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 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
http://www.aspfaq.com/
Jul 19 '05 #1
7 3984
(BTW - Same behavior on XP Pro.)
Jul 19 '05 #2

"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:e#******** ******@TK2MSFTN GP10.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 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'll pick a.
I tried this on W2K Server with WSH5.6, btw.

Ray at home
Jul 19 '05 #3

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


p.s. fso.close? :P

Ray at home
Jul 19 '05 #4
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:e%******** ********@TK2MSF TNGP10.phx.gbl. ..
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
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.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" <aa***@TRASHasp faq.com> wrote in message
news:e%******** ********@TK2MSF TNGP10.phx.gbl. ..
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
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******** ********@TK2MSF TNGP12.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.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" <aa***@TRASHasp faq.com> wrote in message
news:e%******** ********@TK2MSF TNGP10.phx.gbl. ..
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
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
9515
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: absolute;top:68px; left:563px; width:640px;height:480px;"> <IMG src="ReportImageBox_12.54.52.png" width=640 height=480></IMG>
20
3733
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 (3), I think that the answers are all "yes", but I would be glad to have strong confirmation. About questions (4), (5) and (6), I really don't know....
7
1692
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 need to prompt the users with a modal box (with "Yes" and "Cancel" button on it); 2) When the user clicks "Yes" button, I need to do some further...
4
2455
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, as I expected. I haven't seen this behavior explained precisely in the .net world yet, so I wanted to check and make sure I've got it right. I...
2
1170
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 parameter will execute, otherwise, it will not. Is this a correctunderstanding on my part? Thanks, Ike<form name="upcards" onSubmit="return...
5
13037
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 (selectedindexchanged). I have tried adding an onchange attribute "return confirm('sure u wanna change this?';") but it will not postback regardless of the...
6
967
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 treeview tooltips flash if the main form has its transparencykey set?"
1
2031
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 class="falling1"><img src="http://i87.photobucket.com/albums/k139/hi5love/fallinghearts.gif"></span></marquee> <marquee behavior="scroll" direction="down"...
5
11648
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 prevents the default behavior of the event. So, in the onclick of a button the default behavior is to submit the form. Confirm returns the value 1...
0
7551
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7477
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7991
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6084
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5396
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5118
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1971
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.