Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 09:21 AM
jessie
Guest
 
Posts: n/a
Default Create a file with FileSystemObject

This my code for practice:

<html>
<body>
<%
Response.Write("6 ")
dim fs,fname
set fs=CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("f:\test.txt")
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>
</body>
</html>

but I couldn't create the text file at all with no error warning.
How can I do this?

Thanks a lot.

  #2  
Old July 19th, 2005, 09:21 AM
Michael G. Schneider
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

"jessie" <all@ywzc.net> schrieb im Newsbeitrag
news:Xns94257BC3C2408allywzcnet@207.46.248.16...[color=blue]
> This my code for practice:
>
> snipped
>
> but I couldn't create the text file at all with no error warning.
> How can I do this?[/color]

What does the error message say?

The CreateTextFile might fail, because the file already exists (and the
overwrite parameter is not given). Or the CreateTextFile might fail, because
the account does not have enough access rights to the directory.

Michael G. Schneider


  #3  
Old July 19th, 2005, 09:21 AM
jessie
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

[color=blue]
> What does the error message say?
>
> The CreateTextFile might fail, because the file already exists (and
> the overwrite parameter is not given). Or the CreateTextFile might
> fail, because the account does not have enough access rights to the
> directory.[/color]


There is no error message. It is running and nothing comes out.
the overwrite parameter is ture for default, isn't it?
How to give it the right to access to the directory?
Thanks.
  #4  
Old July 19th, 2005, 09:21 AM
Rob Meade
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

"jessie" wrote ...
[color=blue]
> There is no error message.[/color]

You could always try putting some

Response.Write "I got to this step"
Response.Write "Now I am at this step"

etc etc, to see where it gets to before it fails.

You could also check your browser settings to see if you have friendly
errors turned on (if so try turning it off).
[color=blue]
> the overwrite parameter is ture for default, isn't it?[/color]

I believe so, yes.
[color=blue]
> How to give it the right to access to the directory?[/color]

Browse through to the directory you are trying to save the file in,
right-click on it, left-click on properties.
Left-click the security tab, see if the 'IUSR_<computer_name>' account is
listed, if not - try adding it and give it everything but full access (or
give it full access but just for now to test etc).

Now rerun your code - you might want to stick a response.write at the end of
your code to so that you know if its got that far...

Just one question - you showed the F drive above - this will sound daft -
but its not your CD rom drive is it?

Regards

Rob


  #5  
Old July 19th, 2005, 09:21 AM
Michael G. Schneider
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

"jessie" <all@ywzc.net> schrieb im Newsbeitrag
news:Xns94258774CFC02allywzcnet@207.46.248.16...[color=blue]
>[color=green]
> > What does the error message say?
> >
> > The CreateTextFile might fail, because the file already exists (and
> > the overwrite parameter is not given). Or the CreateTextFile might
> > fail, because the account does not have enough access rights to the
> > directory.[/color]
>
>
> There is no error message. It is running and nothing comes out.
> the overwrite parameter is ture for default, isn't it?
> How to give it the right to access to the directory?[/color]

You should look up the CreateTextFile method. I believe, the overwrite is
False by default. The ASP page will be executed under a certain account. If
you do nothing special, this should be the IIS_machine account. This account
needs the access rights to the directory on the IIS Server. For setting the
access right, navigate to the folder, right click, properties, security.

Michael G. Schneider


  #6  
Old July 19th, 2005, 09:21 AM
jessie
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

[color=blue]
> You could always try putting some
>
> Response.Write "I got to this step"
> Response.Write "Now I am at this step"[/color]
I did this, and I found the problem occurs in the CreateTextFile. If I cut
this line, it is Ok.
[color=blue]
> Just one question - you showed the F drive above - this will sound
> daft - but its not your CD rom drive is it?[/color]
It is not my CD rom.

  #7  
Old July 19th, 2005, 09:21 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

www.aspfaq.com/2180



"jessie" <all@ywzc.net> wrote in message
news:Xns9425930EA9FC7allywzcnet@207.46.248.16...[color=blue]
>[color=green]
> > You could always try putting some
> >
> > Response.Write "I got to this step"
> > Response.Write "Now I am at this step"[/color]
> I did this, and I found the problem occurs in the CreateTextFile. If I cut
> this line, it is Ok.
>[color=green]
> > Just one question - you showed the F drive above - this will sound
> > daft - but its not your CD rom drive is it?[/color]
> It is not my CD rom.
>[/color]


  #8  
Old July 19th, 2005, 09:21 AM
Bob Barrows
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

jessie wrote:[color=blue][color=green]
>> What does the error message say?
>>
>> The CreateTextFile might fail, because the file already exists (and
>> the overwrite parameter is not given). Or the CreateTextFile might
>> fail, because the account does not have enough access rights to the
>> directory.[/color]
>
>
> There is no error message. It is running and nothing comes out.
> the overwrite parameter is ture for default, isn't it?
> How to give it the right to access to the directory?
> Thanks.[/color]

Could this be the problem?
http://www.aspfaq.com/show.asp?id=2180

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


  #9  
Old July 19th, 2005, 09:22 AM
jessie
Guest
 
Posts: n/a
Default Re: Create a file with FileSystemObject

"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in news:O9GCn17nDHA.2964
@tk2msftngp13.phx.gbl:
[color=blue]
>
> Could this be the problem?
> http://www.aspfaq.com/show.asp?id=2180
>
> Bob Barrows
>[/color]
Yes, it is!! Thanks!!

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles