> Is this because the Thumbs.db is a system file?
It's because it's a hidden file.
> If so, is there a way to delete system files using code?
You can delete hidden files using code, as follows:
1. Use the Tools > References menu in the VBA editor to set a reference to
Microsoft Scripting Runtime.
2. Create an object variable as follows:
Dim objFSO As Scripting.FileSystemObject
Set objFSO = New Scripting.FileSystemObject
3. Use the following methods as appropriate:
objFSO.DeleteFile
objFSO.DeleteFolder
4. If you need to test for the existence of a file or folder, use these
methods, which return a Boolean (True/False) value:
objFSO.FileExists
objFSO.FolderExists
5. You could loop through all files in a folder using VBA's Dir function.
The Dir function returns a zero-length string when it can't find any more
files. You would need a second loop using the vbHidden constant with the
Dir function to pick up hidden files.
I think this Newsgroup may only be intended for dao/vba questions, but hope
the above helps.
Geoff
"toddr" <(E-Mail Removed)> wrote in message
news:68F838EC-537E-41FC-BF7B-(E-Mail Removed)...
>i have some code that deletes image files from a network folder. the code
> lists the contents of the folder to a file, reads thru and uses the kill
> statement to delete them. once all the files have been removed i want to
> use
> the RmDir command to get rid of the folder. the problem seems to be that
> the
> folder sometimes will contain a Thumbs.db file. the Thumbs.db file does
> not
> seem to get deleted in the code. i have tried Kill (path & "*.*") and Kill
> (path & "thumbs.db") and get an error. I also get an error when i try to
> use
> the RmDir when the thumbs.db file is still in there. If i delete manually
> using windows explorer it works file.
>
> Is this because the Thumbs.db is a system file? If so, is there a way to
> delete system files using code? Anyone?
|