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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystem Object Delete Files (from collection) Problem

Status
Not open for further replies.

mmguru

Programmer
Jul 30, 2001
2
US
Hopefully someone on here can help me. I'm trying to use the FileSystemObject to delete any existing files from a predefined folder. I've looked in the archives and found related solutions but nothing quite like my problem. I've using the code listed at bottom but every time I run it I get the following error from my server:

Microsoft VBScript runtime error '800a0046'

Permission denied

/sorenwest_demo/admin_user.asp, line 446


I have checked the permissions on the server and they are as follows:

(Folder Level Settings in IIS)
SCRIPT SOURCE ACCESS
read checked
write checked
Scripts Only

DIRECTORY SECURITY
Anonymous Access
Account User for Anonymous Access - > IUSR_<computername>
Allow IIS to Control Password


I've played around with all these settings with no luck. Here is my script:

*********************

Case &quot;delete&quot;

'declare variables
Dim objFSO,objFolder,strPhysicalPath,strPath
Dim objCollection,objItem

'set the folder path (hard coded for now)
strPath = &quot;./folders/folder8/&quot;

'create the filesystemobject
strPhysicalPath = Server.MapPath (strPath)
Set objFSO = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
Set objFolder = objFSO.GetFolder (strPhysicalPath)

'delete files in folder
Set objCollection = objFolder.Files

For Each objItem in objCollection
'the first line below works, the second produces a permissions error
response.write (objItem.name & &quot;<BR>&quot;)
objItem.delete
Next

**************

Thanks in advance folks,
Carlos
 
OK, basically you need to check the NTFS permissions on your folder, and makes sure that IUSR_ComputerName has got both read and write access to the folder in which the files you want to delete exist. -GTM Solutions, Home of USITE-
-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top