Re: Kill all text files except those starting with ~$



"Dixie" <dixie@xxxxxxxxxxx> wrote in
news:43878821$1@xxxxxxxxxxxxxxxxxxxxxx:

> I am trying to write some code that when I exit my application
> kills all of the text files in a certain folder. It is
> possible that some of those files are locked because someone
> else is using them, in which case they will have the first two
> letters of their name replaced with ~$. How can I write a
> routine that will delete all the normal *.txt files, but not
> attempt to delete the ~$ ones, which brings up an error
> message and prevents the program from closing. I thought this
> would be easy, but I have not managed to do it after quite a
> while trying.
>
> dixie
>
Scan the directory in question using the dir() function.
Then code an if block that deletes the offending files.

Untested code:

x = dir$("C:\directory to clean")
do while len(x) >0
if left(x,2) <> "~$" then
kill x
endif
x = dir$
loop

--
Bob Quintal

PA is y I've altered my email address.
.



Relevant Pages

  • Kill all text files except those starting with ~$
    ... I am trying to write some code that when I exit my application kills all of ... the text files in a certain folder. ... Prev by Date: ...
    (comp.databases.ms-access)
  • Re: FolderBrowserDialog hangs the application
    ... When I hit the ... One EXIT and one FBD. ... The FBD button does a FolderBrowserDialog and nothing else. ... > I don't even have to pick a folder for this to happen). ...
    (microsoft.public.dotnet.languages.vb)
  • Re: GPO Revent Saving to Desktop ??
    ... Don't Save Settings on Exit: Does not prevent users from adding Programs ... Shortcuts to Desktop ... You can lock the user into their My Documents folder as the ...
    (microsoft.public.win2000.general)
  • Re: vbscript to traverse subfolders
    ... FindFile = True ' return True when found ... ' I believe it puts a log entry for every folder searched ... if FindFile then exit next ' ensure exit from recursion ...
    (microsoft.public.scripting.vbscript)
  • Re: Cant exit from IE
    ... > to exit from the browser. ... Download and install, then you *MUST* update the programs prior to running ... HOLD, download the programs to that folder, then burn that folder to a CD. ... HiJackThis: - Free ...
    (microsoft.public.windows.inetexplorer.ie6.browser)