If Len(Dir("C:\path\filename.ext") > 0 Then
' File filename.ext exists in folder C:\path
Else
' File filename.ext does not exist in folder C;\path
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Steven M. Britton" <(E-Mail Removed)> wrote in message
news:1d3de01c453f1$69d113b0$(E-Mail Removed)...
> What would I use to see if a specific file is in the
> directory?
>
> -Steve
> >-----Original Message-----
> >As Wayne noted you can use the dir function:
> >if dir("c:\path\")>"" then kill "c:\path\*.*"
> >
> >--
> >Please reply to NG only. The email address is not
> monitored.
> >
> >Alex.
> >
> >"Paul Overway" <(E-Mail Removed)>
> wrote in message
> >news:OoZfqU%(E-Mail Removed)...
> >> On Error resume next
> >>
> >> 'If the file doesn't exist...ignore the error
> >> Kill "C:\somefile.txt"
> >>
> >> On Error Goto err_Handler
> >> 'Resume error handling
> >>
> >>
> >> --
> >> Paul Overway
> >> Logico Solutions, LLC
> >> www.logico-solutions.com
> >>
> >>
> >> "Steven M. Britton"
> <(E-Mail Removed)> wrote in message
> >> news:1d6d801c453e4$18d83d10$(E-Mail Removed)...
> >> > Wayne:
> >> >
> >> > I only want to do this in VBA, I use the kill command
> >> > however if there are no files to delete it tells
> me "File
> >> > not found" and exits the sub.
> >> >
> >> > I guess I should further explain my problem. I have
> >> > Access exporting .txt files via a TransferText and a
> >> > query, once I export he .txt files I use Name so that
> I
> >> > can rename them as .CSV files for other various
> uses. A
> >> > problem arises when I try to rename the file and it
> >> > already exist, because the user forgot to erase the
> >> > previous file.
> >> >
> >> > Any Ideas?
> >> >
> >> > -Steve
> >> > >-----Original Message-----
> >> > >You can use the Shell command to do this from a Dos
> >> > window. You can also use
> >> > >the VBA Dir, Kill, ChDir, RmDir, and SetAttr
> commands.
> >> > >
> >> > >To simply delete all files in a folder use
> >> > >
> >> > >Kill <path>\*.*
> >> > >
> >> > >However, this won't remove subdirectories, open
> files, or
> >> > files set as
> >> > >Hidden, System, or Read Only. To do that, you'll
> have to
> >> > use the other
> >> > >commands. To remove subdirectories, you have to run
> >> > through the directory
> >> > >tree recursively. I tend to find it easiest just to
> put
> >> > Deltree (from Dos 6,
> >> > >Win9x) in the path or somewhere that I know where it
> is
> >> > at and Shell to a
> >> > >command prompt calling Deltree. You would call
> >> > Command.com or Cmd.exe with
> >> > >the /C switch.
> >> > >
> >> > >--
> >> > >Wayne Morgan
> >> > >Microsoft Access MVP
> >> > >
> >> > >
> >> > >"Steven M. Britton" <(E-Mail Removed)> wrote in
> message
> >> > >news:1d0b601c453bf$0c4c4340$(E-Mail Removed)...
> >> > >> How can I check to see if there are files in a
> >> > directory,
> >> > >> and if the directory contains files delete all of
> them?
> >> > >>
> >> > >> -Steve
> >> > >
> >> > >
> >> > >.
> >> > >
> >>
> >>
> >
> >
> >.
> >