473,806 Members | 2,605 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 4000
(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
9635
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
3774
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. Please help ! ! !
7
1708
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 processing. If "Cancel" is clicked, of course, stops doing anything; 3) Now the problems are: -...
4
2474
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 apologize that this is a bit long. I've tried to keep it concise. There are code fragments here, but...
2
1180
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 checkdate(this.mydate)"action="/upcards.php?leadid=&upskey=200" method="POST">
5
13056
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 confirm result and the value in the list does not revert back if cancel selected. Is there a solution?
6
973
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
2041
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" scrollamount="2" style="position:absolute; left:169px; top:170px; width:16px; height:411px; z-index:1;"><span...
5
11665
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 if the user clicks OK and the value 0 if
0
9719
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10373
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9192
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.