How to Force Folder Delete if it contains Files?

 
0
 

-->>Hi, here is athing I managed to write Codes that Creates a Folder for a User when Registered...
-->>The Folder takes User's registered name with some additional files inside it,works very fine...
-->>The code I used is this one:

MkDir GetAppPath() & "SPGPAC - File User Files\" & UCase(txtUserName.Text)
MkDir GetAppPath() & "SPGPAC - File User Files\" & UCase(txtUserName.Text) & "\SPGPAC - File Music"
MkDir GetAppPath() & "SPGPAC - File User Files\" & UCase(txtUserName.Text) & "\SPGPAC - File Notices"
MkDir GetAppPath() & "SPGPAC - File User Files\" & UCase(txtUserName.Text) & "\SPGPAC - File Pictures"
MkDir GetAppPath() & "SPGPAC - File User Files\" & UCase(txtUserName.Text) & "\SPGPAC - File Videos"
MsgBox "User Name: " & txtUserName.Text & " Registered Successful.", vbOKOnly + vbInformation, "Registration Completed."

-->>Now the Problem is when the User Account is Closed (Deleted) I need His/Her Parent Folder to be Deleted...
-->>But what happens is the Folder wont delete if there are some Sub Folders or Files in it...
-->>And I get "Access denied" Error the Code I used to Delete the Parent Folder is:

RmDir GetAppPath() & "\SPGPAC - File User Files\" & USER_NAME

-->>Once I delete all Sub Folders with the same line of code I get rid of It!!!
-->>So I was wondering how can I force it Out without considering Sub Folders or Files?...
-->>And an Interesting Point to Me is the Error "Access denied" if there is a Way I can Make the Folders...
-->>Inaccessible outside the Appl I hope it 'll be usefull so that Only Access is granted upon User Login...
-->>in an Application (That is Not accessible by navigating to the Location it resides and just Click to open)
-->>That's all,any help?...

Featured Replies in this Discussion

  • try this ... before putting this code first add references and so goto project menu and then select references option and then select Microsoft Scripting Runtime hope this helps you
    Post Contains: Code
 
1
 

try this

Dim fso As New FileSystemObject
fso.DeleteFolder GetAppPath() & "\SPGPAC - File User Files\" & USER_NAME 

before putting this code first add references and so goto project menu and then select references option and then select Microsoft Scripting Runtime

hope this helps you

Comments
Nice, short and simple!!
 
0
 

-->>That realy helped Me alot and NOW I'm happy...
-->>Thanks rishif2...

 
0
 

-->>WOW!! Sorry almost Forgot what about:

-->>Is there a Way I can Make the FoldersInaccessible outside the Appl I hope it 'll be usefull so that Only Access is granted upon User Login...
-->>in an Application (That is Not accessible by navigating to the Location it resides and just Click to open)

 
0
 

I actually had the same scenario a while ago. There is no real solution to your problem because of admin right and non-admin right users. There is some software that you can use to protect a folder but that will mean that you have to run 3rd party apps to get what you want.

Don't know if anyone else here might have a solution to this. I have searched for quite some time and abondoned the entire idea. I moved over to MySql and started running my apps from a server with the databases residing there where all necessary security was in place...

 
0
 

-->>Thank You AndreRet,I also have decided to Move on and I was passing through the...
-->>Inno Setup Compiler Software Version 5.5.1 Inno Setup
-->>This documentation Explains some how on treating Application Files/Folder...
-->>I think it 'll lead Me some how,I'll let You know once I made it...
-->>Thanks...

 
0
 

Only a pleasure as usual. When done, don't forget to mark it as answered, thanx. :)

Question Answered as of 2 Years Ago by AndreRet and rishif2
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article