Link to home
Start Free TrialLog in
Avatar of isnoend2001
isnoend2001Flag for United States of America

asked on

path File access error

I keep getting path File access error here error 75 and cannot determine why:
The directory only has 1 file i kill it then try to remove the directory
FileName = C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\RedWood Deck Bids\Bids.dat

If FileExists(FileName) Then
                
                Kill FileName

mstrDirectoryToRemove = C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\RedWood Deck Bids
RmDir mstrDirectoryToRemove' [b]path File access error here[/b]

Open in new window

What could cause this ?
Avatar of epichero22
epichero22
Flag of United States of America image

Just a guess, but could it be that you don't have quotes around the dir name?
Avatar of Qlemo
Omitting the double quotes should lead to compiler errors - it is a syntax error.

The access error probably results from hidden files still being in the folder. The Thumbnail cache file used for storing the thumbnail pictures in Explorer is one you often find in folders.
Avatar of isnoend2001

ASKER

Thanks epichero22, but dir name is a variable
Dim mstrDirectoryToRemove As String
Thanks Qlemo,my app created the folder and only puts in 1 file(Bids.dat)
That does not contradict what I say. Did you check with e.g.
   attrib *
in a command prompt? That should list all files and folders, even system or hidden.
I can close the app and then reopen and delete the directory without issues
Seems that the RmDir right after killing the file causes the issue
I am going to try this:
1. Kill the file
2. Put the RmDir in a command button and try that
The application is closed when you try to remove the folder?
Qlemo, No its open, but no files are open this  works
I can click a button to kill the file
And Click another button to remove the directory

I will try to put both in one button
Putting both the kill and remove directory in a button works, don't know why
Private Sub Command2_Click()
Dim FileName As String
FileName = GetPathToCboItem(cboBids.Text) & "\Bids.dat"
mstrDirectoryToRemove = GetPathToCboItem(cboBids.Text)
 Kill FileName
RmDir mstrDirectoryToRemove

End Sub
Can we consider that as sufficient? If so, just delete the question.
No I have not found a solutation
Why? Do you need to put that into something else than a button? I don't know how we should be able to help ATM.
yes the directories to delete are in a combobox. User selects a name and clicks the delete button the file is killed (if it exists) and the directory is removed. this is what gives the error. Putting both in a command button I initially thought worked, but further testing gave the same error
I am going to try this:
It seems that the  RmDir works the next time the form is loaded not sure
I will put the path in an ini file and delete the directory the next time the form is loaded.
This should not need to be done, but for the time being this may be a work around, if it works
If that is the case, you still have something accessing the folder. E.g. setting it as current directory - some file selection boxes do that by default
Thanks Qlemo
My workaround did not work, still the same error.
I have an ini file here C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\AppFolder
It is in the same path, could this be causing the problem ?
You told us that there is NO other file, now there is an INI in the same folder? Of course that will prevent removing the folder.
The file  is not in the folder I am trying to remove only in the path
I have an ini file here C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\AppFolder
folder to remove:
C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Bryant 4587 lotta way\RedWood Deck Bids
Then there is no relation, the INI file does not matter.
Do you use anything like a dialog to choose a path and or file name using the filesystem?
At the same moment you get the error in your application, are you able to delete the folder in Explorer while the app still runs?
Do you use anything like a dialog to choose a path and or file name using the filesystem?
No the folder and folder title is created when typed into a combox
Private Function OpenFromFile()'should have been a sub
            On Error GoTo e
            Dim FF As Integer
            Dim MyFile As String 'added
20          FF = FreeFile
30          
             MyFile = mstrSelectedCboPath'
40     If FileExists(MyFile) Then 'FileExists in module
50          Open MyFile For Binary As #FF
60            Get #FF, , ArrayDim
70            ReDim RoofCompany(ArrayDim)
80            Get #FF, , RoofCompanyTotal
90            Get #FF, , RoofCompany
100         Close #FF
110      Else
120         Exit Function
130     End If
140      Exit Function
e:
      ShowError err.Number, err.Description, "Function OpenFromFile", Erl 'write to file and display error
End Function

the save is pretty much the same:
ArrayDim = UBound(RoofCompany)'should have been a sub
      Open MyFile For Binary As #FF
        Put #FF, , ArrayDim
        Put #FF, , RoofCompanyTotal
        Put #FF, , RoofCompany
      Close #FF
no the folder cannot be deleted thru Explorer "access denied error, but i can kill the file thru the app, just not the folder
The app looks like this:
User generated image
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for you efforts