deletefolder

deletefolder

Anonymous
Not applicable
275 Views
1 Reply
Message 1 of 2

deletefolder

Anonymous
Not applicable
Hi Guys and Girls,

I am having an issue with the deletefolder method.

An outline of what I am trying to achieve:
1. Creating directory structure copying template folders to the created project folder
2. If there is Plot.dwt file missing, I have exited the program, and deleted the folder just created (this bit works).
3. Once we get into the main area, if the user clicks cancel, I want the folder to be deleted, however it errors with "Permission denied"

The code that works:
'Test to see if file is there
If Dir$(dwgname, vbReadOnly) = "" Then 'no file present
MsgBox "Can not find the Plot.dwt file in " & TxtLocation & ". Please ensure it is there and try again.", vbCritical, Me.Caption

'delete folder that was created so the user can retry
Dim fs As FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFolder StrPath + TxtProjNum, True
Dim BlnNoFile As Boolean
BlnNoFile = True
GoTo NoFile

***********************************************************************
The code that doesn't

Private Sub CmdCancel_Click()
If MsgBox("You are about to cancel the Project.inf setup. Do you wish to remove the project folder too?" & vbCrLf & vbCrLf _
& "Note: leaving the folder structure in will prevent you from creating the project.inf file in future.", vbInformation + vbYesNo, Me.Caption) = vbYes Then

'delete folder that was created so the user can retry
Dim fs As FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFolder StrPath + TxtProjNum, True
End If

Unload Me
End Sub

any suggestions would be great

Thanks
Brent
0 Likes
276 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
I have managed to isolate what causes this - it is the line

If Dir$(dwgname, vbReadOnly) = "" Then 'no file present
'Stuff
End If

Although I have found it, I can not seem to understand how an If statement can cause this to occur, as nothing is being set. Any ideas??

Thanks
Brent
0 Likes