Check directory for data

  • Thread starter Thread starter Sash
  • Start date Start date
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
 
Hi Sash

Take out the vbDirectory. This option tells Dir to search for directories
(folders), not files.
 
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
 
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
 
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
 
Back
Top