I am working with the following block of code, and I keep getting an Error 70 at the point where the program is trying to remove the directory that it created. This code should be fairly straight forward, but I must be missing something simple. I first thought it was the direct calls to "If Len(Dir$(FilesStr)) Then..." so I changed it to use a long integer. This seemed to work for a short time, but now it is once again failing.
I can easily remove the folder from the DOS prompt or Windows Explorer once the program creates it. The file gets deleted just fine, but the folder does not get removed. I am running this on Windows XP SP2.
I can easily remove the folder from the DOS prompt or Windows Explorer once the program creates it. The file gets deleted just fine, but the folder does not get removed. I am running this on Windows XP SP2.
Code:
#Compile Exe #Dim All $WorkDir = "\RMVTEST\" $BaseFileName = "MyBase_" $FileExtension = ".dat" %Buf512K = 524288 %USEMACROS = 1 #Include "win32api.inc" #Include "CommCtrl.inc" Global hDlg As Dword Sub CheckDrive Local drive As String Local FilesStr As String Local rslt As Long drive = "C:" FilesStr = drive & $WorkDir & $BaseFileName & "*" & $FileExtension MkDir drive & $WorkDir If ErrClear Then MsgBox "Error Making Directory" Open drive & $WorkDir & $BaseFileName & "01234" & $FileExtension For Output As 1 Print# 1, "This is a test file for this routine!" Close 1 If ErrClear Then MsgBox "Error Making File" rslt = Len(Dir$(drive & $WorkDir & "NUL")) If rslt Then ' scrub folder exists! See if there are files in it rslt = Len(Dir$(FilesStr)) If rslt Then If MessageBox(hDlg, "Folder w/ File Exists, Remove it?", _ "Drive " & drive, %mb_yesno Or %mb_iconquestion) = %idyes Then ErrClear Kill FilesStr ' Delete any files we created ErrClear RmDir drive & $WorkDir If Err Then MessageBox hDlg, "Error " & Format$(Err) & " attempting to remove folder!", "Could Not Remove", 16 ErrClear End If End If End If End If End Sub Function PBMain () As Long CheckDrive End Function
Comment