Message 1 of 2
deletefolder
Not applicable
02-21-2008
05:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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