Can someone please help?

  • Thread starter Thread starter Omega Warrior
  • Start date Start date
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!
 
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
 
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!
***********************************************
 
Back
Top