Can someone please help?

O

Omega Warrior

I'm having a difficulty...


Dim fso

Dim filename

fso = CreateObject("Scripting.FileSystemObject")

Dim File, Folder, FileCollection



Folder = fso.GetFolder("C:\test\")

FileCollection = Folder.Files

For Each File In FileCollection

fso.DeleteFile(File)

Next





and when i run this code I get the following error:

An unhandled exception of type 'System.Security.SecurityException' occurred
in microsoft.visualbasic.dll

Additional information: Exception from HRESULT: 0x800A0046
(CTL_E_PERMISSIONDENIED).





Its like it wont give me ermission to do that. How do I enable the
permission to do that?





Thank you!
 
K

Kevin Spencer

You have absolutely no reason to use the COM Scripting.FileSystemObject
object in a .Net application. Use the System.IO namespace classes instead.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
 
C

Cowboy \(Gregory A. Beamer\)

Is this a .NET application. If so, consider using the classes in the
System.IO namespace instead.

If it is COM, you are in the wrong group, but I might be able to help
none-the-less.

Is this a web application or a desktop application? If a web application,
the delete rights on the folder and file have to be granted to the IUSR
account, if anonymous access is set up, or the user who the app is running
under, if the user logs in. If a desktop application, grant rights to the
user; if this app is deleting off a folder on another machine, this can get
tricky.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top