View Full Version : Permission Denied Error Creating a File

05-04-2006, 02:33 PM
Hi there,

I am having real problems with file permissions with the FileSystemObject in VBScript and need some advice.

This is the code I am using:

Dim Data
Data = "c:\Data.css"
Set FileToWrite = Server.CreateObject("Scripting.FileSystemObject")

If FileToWrite.FileExists(Data) Then
FileToWrite.DeleteFile Data, True
Set StyleWrite = FileToWrite.CreateTextFile(Data)
Set FileToWrite = FileToWrite.CreateTextFile(Data)**
End If

At present the file Data.css exists. If it doesn't exist I want to create a new one and if not I want to delete the file and recreate it. I have set all permissions I can think of for the Internet and Web guest accounts on the C drive, but it will not allow it to be deleted and gives a permissions denied error.
If the code to delete the file is commented out and you allow the file to be overwritten instead by changing the creation file code to:

Set FileToWrite = FileToWrite.CreateTextFile(Data, True)

This gives the same permission denied error :mad:

The asp page I am running with this code is running off my localhost and is being debugged in VS.NET.
Any suggestions on what might be wrong and what settings to re-check.

05-09-2006, 07:02 PM
I don't know if this will help, but I found it in a forum. It was posted by a user who was also receiving a permission denied error when trying to use .DeleteFile()

if you're running Norton Antivirus, there's a section called "script blocking" which blocks out dangerous script, and since the file system object is logging onto my pc to get information Norton see's it as a problem and blocks access. so i turned that one fuction off and file system object works fine.