[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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 ?
0
isnoend2001
Asked:
isnoend2001
  • 14
  • 9
3 Solutions
 
epichero22Commented:
Just a guess, but could it be that you don't have quotes around the dir name?
0
 
QlemoDeveloperCommented:
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.
0
 
isnoend2001Author Commented:
Thanks epichero22, but dir name is a variable
Dim mstrDirectoryToRemove As String
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
isnoend2001Author Commented:
Thanks Qlemo,my app created the folder and only puts in 1 file(Bids.dat)
0
 
QlemoDeveloperCommented:
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.
0
 
isnoend2001Author Commented:
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
0
 
QlemoDeveloperCommented:
The application is closed when you try to remove the folder?
0
 
isnoend2001Author Commented:
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
0
 
isnoend2001Author Commented:
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
0
 
QlemoDeveloperCommented:
Can we consider that as sufficient? If so, just delete the question.
0
 
isnoend2001Author Commented:
No I have not found a solutation
0
 
QlemoDeveloperCommented:
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.
0
 
isnoend2001Author Commented:
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
0
 
QlemoDeveloperCommented:
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
0
 
isnoend2001Author Commented:
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 ?
0
 
QlemoDeveloperCommented:
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.
0
 
isnoend2001Author Commented:
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
0
 
QlemoDeveloperCommented:
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?
0
 
isnoend2001Author Commented:
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
0
 
isnoend2001Author Commented:
The app looks like this:
App image
0
 
QlemoDeveloperCommented:
I didn't test, but I guess the Open will keep the folder in access (but not the file). For debugging, you can see if I'm correct if you display CurDir after closing the file. You can also try if a ChDir("..") after Close allows to delete the folder.
0
 
isnoend2001Author Commented:
Thanks Qlemo
After closing the file
ChDir "C:\Documents and Settings\All Users.WINDOWS\Documents"
Debug.Print CurDir' displays this
"C:\Documents and Settings\All Users.WINDOWS\Documents"
I thought this might allow deleting the directory, but it did not.
Did not try deleting thru code only using Windows explorer gives  cannot delete in Use, close any programs that may be using it"
0
 
isnoend2001Author Commented:
Found This same problem
http://forums.codeguru.com/showthread.php?310799-Cannot-delete-folder

Dir "C:\"
This  fixes the issue
0
 
isnoend2001Author Commented:
Thanks for you efforts
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 14
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now