Check directory for data

S

Sash

I'm trying to check a directory for tif files and if they exists, I want to
get rid of them all. Here's what I tried, but it doesn't work.

dirPath = Dir("D:\02691568\Temp\*.tif", vbDirectory)
If Not IsNull(dirPath) Then
Kill "D:\02691568\Temp\" & "*.tif"
End If
 
G

Graham Mandeno

Hi Sash

Take out the vbDirectory. This option tells Dir to search for directories
(folders), not files.
 
S

Sash

Thank you!!! But, I took it out and when there's nothing in the directory, I
get "File Not Found".

Graham Mandeno said:
Hi Sash

Take out the vbDirectory. This option tells Dir to search for directories
(folders), not files.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sash said:
I'm trying to check a directory for tif files and if they exists, I want
to
get rid of them all. Here's what I tried, but it doesn't work.

dirPath = Dir("D:\02691568\Temp\*.tif", vbDirectory)
If Not IsNull(dirPath) Then
Kill "D:\02691568\Temp\" & "*.tif"
End If
 
S

Sash

Figured it out and thought this might help someone else...

dirPath = Dir("D:\HIM\02691568\Temp\*.tif")
If Len(dirPath) > 0 Then
Kill "D:\HIM\02691568\Temp\" & "*.tif"
End If



Sash said:
Thank you!!! But, I took it out and when there's nothing in the directory, I
get "File Not Found".

Graham Mandeno said:
Hi Sash

Take out the vbDirectory. This option tells Dir to search for directories
(folders), not files.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sash said:
I'm trying to check a directory for tif files and if they exists, I want
to
get rid of them all. Here's what I tried, but it doesn't work.

dirPath = Dir("D:\02691568\Temp\*.tif", vbDirectory)
If Not IsNull(dirPath) Then
Kill "D:\02691568\Temp\" & "*.tif"
End If
 
G

Graham Mandeno

Ah yes - I didn't notice you were also checking for Null. Dir() always
returns a string which may be empty (zero length) but never null.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Sash said:
Figured it out and thought this might help someone else...

dirPath = Dir("D:\HIM\02691568\Temp\*.tif")
If Len(dirPath) > 0 Then
Kill "D:\HIM\02691568\Temp\" & "*.tif"
End If



Sash said:
Thank you!!! But, I took it out and when there's nothing in the
directory, I
get "File Not Found".

Graham Mandeno said:
Hi Sash

Take out the vbDirectory. This option tells Dir to search for
directories
(folders), not files.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I'm trying to check a directory for tif files and if they exists, I
want
to
get rid of them all. Here's what I tried, but it doesn't work.

dirPath = Dir("D:\02691568\Temp\*.tif", vbDirectory)
If Not IsNull(dirPath) Then
Kill "D:\02691568\Temp\" & "*.tif"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top