Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't create a text file using ASP

Status
Not open for further replies.

Hawki

Programmer
Oct 16, 1999
63
0
0
US
Hi

Can someone help me because I’m going to shoot this computer. I’ve been trying to write a file and have been having problems in doing so. The code I’ve been using can see if a file is there but when I go to write it start a very very slow load in the browser and then times out. I get no error and the file is never created. What is wrong?

Using Windows 2000 pro and IIS = PWS

<!-- #include file="adovbs.inc" -->
<html>
<body>

<%

dim fs,fname


Set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("D:\Inetpub\
If (fs.FileExists("D:\Inetpub\ Then
Response.Write("File D:\Inetpub\ exists.")
Else
Response.Write("File D:\Inetpub\ does not exist.")
End If

set fs=nothing
%>

</body>
</html>
 
Try this

<%
Dim myFSO
'this line creates an instance of the File Scripting Object named myFSO
SET myFSO = Server.CreateObject("Scripting.FileSystemObject")
'error handling here to make sure that things go smoothly
'if the file does not exist
If NOT myFSO.FileExists("C:\Inetpub\ Then
'then we create it on this drive in the path we specify
myFSO.CreateTextFile("C:\Inetpub\Else
'otherwise we tell the client it does so they don't get a nasty error
Response.Write "THIS FILE ALREADY EXISTS"
End If
'this line destroys the instance of the File Scripting Object named myFSO
SET myFSO = NOTHING
%>

Regards,


Lewis Harvey
lewis@lharvey.com
 
Also make sure you don't have a firewall or antivirus program ruinning that blocks scripting, this is a common problem (and annoyance) that causes issues with FSO objects.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Check that IUSR_*** has write permissions to directory where you intend to write file too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top