Kill not working

kirkm

Registered User.
Local time
Tomorrow, 06:13
Joined
Oct 30, 2008
Messages
1,257
I'm getting run time error 75 File/Path access error using a valid & correct path and filename.
However the drive is a mapped Network drive. Is this why and any solution?
Thanks.
 
Check for permissions. From the machine hosting your database (or database front end, either one), if you can't kill the file manually via the Command Prompt window or the File Explorer window, then Access won't be able to kill it either. Note specifically that the permissions on the file in local context will not always be the file permissions from a network context, since the Share CAN have its own permissions.

Also, is that network path intercepted by a firewall that filters "rogue" apps? I've had cases where I could not do an SMTP from my machine because the firewall hadn't expected my machine to touch the SMTP gateway machine.
 
use the mapped drive letter.
also if you are saving tmp files, better save it locally.
 
I was using the mapped drive letter, as part of the complete filespec in a string variable, but no Kill.
Eventually I succeeded with
Code:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile TheFile, True
Although I don't know what the "true" does.
BTW Del from command prompt did work.
 
Was the file still open? Kill will fail on an open file.

I always add an overwrite and file open check whenever I am saving files locally or on the network.
 
@kirkm
The True/False argument in the line fso.DeleteFile FileName, True is optional.
That code can be used to delete multiple files at once using wildcards

If it is set True, only read only files are deleted. If false all files are deleted. The default if the argument is omitted is False
 
I was using the mapped drive letter, as part of the complete filespec in a string variable, but no Kill.
Eventually I succeeded with
Code:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile TheFile, True
Although I don't know what the "true" does.
BTW Del from command prompt did work.
What if it had meant Delete parent and all subfolders? :(
 
This uses intrinsic VBA commands.
It gives error 70 if the file is open.
error 53 for file not found

Code:
Sub killfile()
Dim f As String

f = "D:\filename.txt"
On Error GoTo fail
Kill f
MsgBox "file deleted: " & f
Exit Sub


fail:
    MsgBox "Error: " & Err & "    Description: " & Err.Description

End Sub
 
Between the command prompt, Kill, and FSO delete file: None of them can work magic. I.E., delete a file someone has a lock on by having it open (if it's such a file that a lock is created in such a condition).

My guess is that nothing would delete it because of something happening with the file, and coincidentally (but not significantly), when you used FSO at that time it was delete-able.
 
The file wasn't read only or Open or locked. KIll failed (in Access), DEL from command prompt (and FSO in Access) worked.
And FSO was True.
>What if it had meant Delete parent and all subfolders?
It was a file, not a folder.
Normally Kill is ok, so it must be a Network limitation.
Gemma it was error 75, not 70 or 53, and complaining about a (perfectly good) path.,
 
KIll failed (in Access), DEL from command prompt (and FSO in Access) worked.
With all due respect, I'm suggesting that's not possible. There must have been something else you didn't notice about the file that changed between you trying Kill and FSO. OR, that changed about your network connectivity.

The file wasn't read only or Open or locked
How do you know?
 
I'd just created it. It wasn't being accessed by anything. This is something done often and no other (local drive) files have resulted in that error. I did suspect a typo but it definately wasn't. I may be able to replicate it... will advise.
 
Yes Isaac, it was read-only and shouldn't have been. Can't quite see why it was... but still that's not a Pathing problem.
 
I'll say it again, use a check to a) make sure it exists, b) is it open, before trying to anything with it.
a) isn't required if you have just created it, but might be if you want to overwrite an existing version.
 
Gemma it was error 75, not 70 or 53, and complaining about a (perfectly good) path.,

I tried a non existent path and I still got error 53
Error 75 is showing as Path/File access error

I tried various things, and couldn't get Error 75

I don't know the difference between Error 75 and Error 53. Maybe the path exists and it's a permission error.

see this. This mentions changing a read-only file, so maybe deleting a read-only file is also prevented.
Path/File access error (Error 75) | Microsoft Docs


I then found this which indeed says you can't kill a read-only file, so that's probably why all your other methods are failing as well
 
Last edited:

Users who are viewing this thread

Back
Top Bottom