From: Jim Gregg on
Hello,

I have a vbscript which creates a text file, add some lines of text,
and then tries to save it. The problem is that when I try to save the
file, I get an error stating "bad file name or number" with the
following line of code:

Set objFile = objFSO.CreateTextFile(strPath, True)
objFile.Write(strList)
objFile.Close

strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the
name. The application that I am updating this file for expects it to
be named FILE with no extension. I can only assume that the error is
coming from the fact that vbscript thinks FILE is a directory name. Is
there anyway to do this with a text file with no extension? Thanks for
any help you can offer.

JG
From: McKirahan on
"Jim Gregg" <crazytek(a)gmail.com> wrote in message
news:4b0d9f38-250a-4685-9d92-9537623d2c41(a)c65g2000hsa.googlegroups.com...
> Hello,
>
> I have a vbscript which creates a text file, add some lines of text,
> and then tries to save it. The problem is that when I try to save the
> file, I get an error stating "bad file name or number" with the
> following line of code:
>
> Set objFile = objFSO.CreateTextFile(strPath, True)
> objFile.Write(strList)
> objFile.Close
>
> strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the
> name. The application that I am updating this file for expects it to
> be named FILE with no extension. I can only assume that the error is
> coming from the fact that vbscript thinks FILE is a directory name. Is
> there anyway to do this with a text file with no extension? Thanks for
> any help you can offer.

The following works for me:

Option Explicit
Const cFIL = "C:\Temp\FILE"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objCTF
Set objCTF = objFSO.CreateTextFile(cFIL, True)
objCTF.Write("Hello World")
Set objCTF = Nothing
Set objFSO = Nothing

Perhaps, your path "C:\Program Files\Some App\" does not exist.

What's your O/S?


From: Richard Mueller [MVP] on
Jim Gregg wrote:

> I have a vbscript which creates a text file, add some lines of text,
> and then tries to save it. The problem is that when I try to save the
> file, I get an error stating "bad file name or number" with the
> following line of code:
>
> Set objFile = objFSO.CreateTextFile(strPath, True)
> objFile.Write(strList)
> objFile.Close
>
> strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the
> name. The application that I am updating this file for expects it to
> be named FILE with no extension. I can only assume that the error is
> coming from the fact that vbscript thinks FILE is a directory name. Is
> there anyway to do this with a text file with no extension? Thanks for
> any help you can offer.

I'm not able to duplicate the problem. I can create a file with no extension
(called FILE) with similar code.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


From: ekkehard.horner on
Jim Gregg schrieb:
> Hello,
>
> I have a vbscript which creates a text file, add some lines of text,
> and then tries to save it. The problem is that when I try to save the
> file, I get an error stating "bad file name or number" with the
> following line of code:
>
> Set objFile = objFSO.CreateTextFile(strPath, True)
> objFile.Write(strList)
> objFile.Close
>
> strPath is equal to "C:\Program Files\Some App\FILE" where FILE is the
> name. The application that I am updating this file for expects it to
> be named FILE with no extension. I can only assume that the error is
> coming from the fact that vbscript thinks FILE is a directory name. Is
> there anyway to do this with a text file with no extension? Thanks for
> any help you can offer.
>
> JG

If there is a directory "C:\Program Files\Some App\FILE", an attempt
to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail
with a "permission denied" error.
From: mayayana on

>
> If there is a directory "C:\Program Files\Some App\FILE", an attempt
> to .CreateTextFile( "C:\Program Files\Some App\FILE", True ) will fail
> with a "permission denied" error.

That's a different issue and would typically only
apply to Vista.