Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Create a file with FileSystemObject

Reply
Thread Tools

Create a file with FileSystemObject

 
 
jessie
Guest
Posts: n/a
 
      10-31-2003
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.

 
Reply With Quote
 
 
 
 
Michael G. Schneider
Guest
Posts: n/a
 
      10-31-2003
"jessie" <(E-Mail Removed)> schrieb im Newsbeitrag
news:Xns94257BC3C2408allywzcnet@207.46.248.16...
> 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?


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


 
Reply With Quote
 
 
 
 
jessie
Guest
Posts: n/a
 
      10-31-2003

> 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.



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.
 
Reply With Quote
 
Rob Meade
Guest
Posts: n/a
 
      10-31-2003
"jessie" wrote ...

> There is no error message.


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).

> the overwrite parameter is ture for default, isn't it?


I believe so, yes.

> How to give it the right to access to the directory?


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


 
Reply With Quote
 
Michael G. Schneider
Guest
Posts: n/a
 
      10-31-2003
"jessie" <(E-Mail Removed)> schrieb im Newsbeitrag
news:Xns94258774CFC02allywzcnet@207.46.248.16...
>
> > 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.

>
>
> 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?


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


 
Reply With Quote
 
jessie
Guest
Posts: n/a
 
      10-31-2003

> You could always try putting some
>
> Response.Write "I got to this step"
> Response.Write "Now I am at this step"

I did this, and I found the problem occurs in the CreateTextFile. If I cut
this line, it is Ok.

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

It is not my CD rom.

 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      10-31-2003
www.aspfaq.com/2180



"jessie" <(E-Mail Removed)> wrote in message
news:Xns9425930EA9FC7allywzcnet@207.46.248.16...
>
> > You could always try putting some
> >
> > Response.Write "I got to this step"
> > Response.Write "Now I am at this step"

> I did this, and I found the problem occurs in the CreateTextFile. If I cut
> this line, it is Ok.
>
> > Just one question - you showed the F drive above - this will sound
> > daft - but its not your CD rom drive is it?

> It is not my CD rom.
>



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      10-31-2003
jessie wrote:
>> 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.

>
>
> 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.


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.


 
Reply With Quote
 
jessie
Guest
Posts: n/a
 
      10-31-2003
"Bob Barrows" <(E-Mail Removed)> wrote in news:O9GCn17nDHA.2964
@tk2msftngp13.phx.gbl:

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

Yes, it is!! Thanks!!

 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't create object: 'Scripting.FileSystemObject' Astra ASP General 4 12-20-2005 09:36 PM
ActiveX component can't create object: 'Scripting.FileSystemObject' Astra ASP General 1 12-13-2005 01:00 PM
Check file exist without using Server.CreateObject("Scripting.FileSystemObject") Lin Ma ASP General 2 06-10-2004 09:26 PM
IIS 5.0 / Win2k Hangs up when Reading file using Server.FileSystemObject Pedro Bautista ASP .Net 0 08-28-2003 11:56 PM
Deleting a file with the FileSystemObject Roger Withnell ASP General 3 07-14-2003 10:49 PM



Advertisments