Solved

path File access error

Posted on 2014-10-24
24
136 Views
Last Modified: 2014-10-31
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
Comment
Question by:isnoend2001
  • 14
  • 9
24 Comments
 
LVL 11

Expert Comment

by:epichero22
ID: 40402416
Just a guess, but could it be that you don't have quotes around the dir name?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40402449
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
 

Author Comment

by:isnoend2001
ID: 40402454
Thanks epichero22, but dir name is a variable
Dim mstrDirectoryToRemove As String
0
 

Author Comment

by:isnoend2001
ID: 40402464
Thanks Qlemo,my app created the folder and only puts in 1 file(Bids.dat)
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40402492
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
 

Author Comment

by:isnoend2001
ID: 40402522
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40402579
The application is closed when you try to remove the folder?
0
 

Author Comment

by:isnoend2001
ID: 40402609
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
 

Author Comment

by:isnoend2001
ID: 40402662
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40403305
Can we consider that as sufficient? If so, just delete the question.
0
 

Author Comment

by:isnoend2001
ID: 40403468
No I have not found a solutation
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40403936
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:isnoend2001
ID: 40403956
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40404028
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
 

Author Comment

by:isnoend2001
ID: 40404064
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40404073
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
 

Author Comment

by:isnoend2001
ID: 40404093
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40404222
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
 

Author Comment

by:isnoend2001
ID: 40405049
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
 

Author Comment

by:isnoend2001
ID: 40405052
The app looks like this:
App image
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 500 total points
ID: 40405490
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
 

Assisted Solution

by:isnoend2001
isnoend2001 earned 0 total points
ID: 40405592
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
 

Accepted Solution

by:
isnoend2001 earned 0 total points
ID: 40405613
Found This same problem
http://forums.codeguru.com/showthread.php?310799-Cannot-delete-folder

Dir "C:\"
This  fixes the issue
0
 

Author Closing Comment

by:isnoend2001
ID: 40415292
Thanks for you efforts
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now