From: Ulrich Korndoerfer on
Hi,

Saga schrieb:
> Hi All,
>
> I have a routine that deletes files that are older than X days. I get the
> file names into an array then I for each filename I determine if it is older
> than X days and if it is I delete it. I use the Dir$() and Kill functions
> for this. It works as expected when there are few files in the folder, but
> takes a loooong time when there are tens of thousand of files.
>
> My peeve is that I need to check the age of the file and delete it only if
> it older than the number of specified days. I searched for different
> routines, but none of them illustrate what I need to do. Does any one have
> any suggestions on an alternative, faster way to do this? Thanks! Saga

Don't know how your code is and where the bottleneck is. But I can offer
a class called CFileSearch that does the first part, searching for files
and delivering file infos including the created and modified dates,
really quick (uses the Windows file apis):

<http://www.prosource.de/Downloads/indexe.html#FileSearch>
<http://www.prosource.de/Downloads/VB_Quickies/CFileSearch.zip>

After getting all files infos it is easy to determine wether a file
shall be deleted by comparing its dates (VB type Date).

--
Ulrich Korndoerfer

VB tips, helpers, solutions -> http://www.proSource.de/Downloads/
From: Dee Earley on
On 23/10/2009 23:42, Nobody wrote:
> "Eduardo"<mm(a)mm.com> wrote in message news:hbst9b$is4$1(a)aioe.org...
>> When doing it manually through the windows explorer, I found that it's
>> much faster to delete a folder with all its files, than deleting all the
>> files first.
>>
>> But it must be because it sends them to the reclicle bin. In the case of
>> deleting a folder it has to move just one object to the recicle bin.
>
> <Extremely dangerous idea ahead>
>
> Press Shift+Delete to delete files permanently, without sending them to the
> Recycle Bin. The same is true for deleting email in some email programs,
> just try not to make a habit of it. It's easy to press Shift+Delete followed
> by Enter. It's better to be safe than sorry!
>
> </Extremely dangerous idea ahead>

It's still stupidly slow on lots of file.
And yes, it is a very bad habit to have got into :)

> Please forgot what I said above.

I wish I could!

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems
From: Saga on
Thank you all for your ideas. I was out from Fri to Sun eve at iHobbyExpo
and only now am I getting settled back in.

Thanks for the links to routines, examples and more information. I will have
a look at them. Both Bob and Dee have a good idea in that perhaps it isn't
so much making the delete process faster, instead a differrent approach is
necessary. Grouping the files into folders and then only checking and
deleting
the folders would definitely be a better to do do this process.

OpenVMS sounds interesting, but not the solution for this particular case
because it involves a new (and different) piece o software, thus having to
go
through a Dilbertian approval process. :-S Thanks for this idea though. I
will look into this.

The delete process runs various times a day. Obviously, it is the first time
that
it is run that takes an extremely long time. However; running it during non
business hours is a good idea and I am able to schedule it within the main
app.

Karl, the botteneck occurrs at each step. Getting the file names, checking
for its date and then deleting it. I am moving away from using Dir() and
more the Windows API calls. After looking at the code and performing
some tests on Thursday I came to the conclusion that the process needed
a major overhaul.

Nothing against using the file object, but I suspect that the security
people
would want my head if I attempted to use it. As much as it could be a good
solution, I'll have to look elsewhere.

Again, thanks for all your ideas. Saga


From: Karl E. Peterson on
Nobody wrote:
> "Eduardo" <mm(a)mm.com> wrote in message news:hbst9b$is4$1(a)aioe.org...
>> When doing it manually through the windows explorer, I found that it's
>> much faster to delete a folder with all its files, than deleting all the
>> files first.
>>
>> But it must be because it sends them to the reclicle bin. In the case of
>> deleting a folder it has to move just one object to the recicle bin.
>
> <Extremely dangerous idea ahead>
>
> Press Shift+Delete to delete files permanently, without sending them to the
> Recycle Bin. The same is true for deleting email in some email programs,
> just try not to make a habit of it. It's easy to press Shift+Delete followed
> by Enter. It's better to be safe than sorry!
>
> </Extremely dangerous idea ahead>
>
> Please forgot what I said above.

I can one-up that! <eg> Right-click on Recycle Bin, select Properties, check off
"Do not move files to the Recycle Bin. Remove files immediately when deleted."
Saves having to press Shift so many times. If you really want something to be
temporarily deleted (how often is that?) you can still drag it to the Recycle Bin.
:-)

Bonus points, you can also turn off that annoying, "Did you really mean to do that?"
dialog, if you're *really* feeling gutsy. <gd&r>
--
..NET: It's About Trust!
http://vfred.mvps.org


From: Eduardo on

>> Press Shift+Delete to delete files permanently, without sending them to the
>> Recycle Bin. The same is true for deleting email in some email programs,
>> just try not to make a habit of it. It's easy to press Shift+Delete followed
>> by Enter. It's better to be safe than sorry!
>>
>> </Extremely dangerous idea ahead>
>>
>> Please forgot what I said above.
>
> I can one-up that! <eg> Right-click on Recycle Bin, select Properties, check off
> "Do not move files to the Recycle Bin. Remove files immediately when deleted."
> Saves having to press Shift so many times. If you really want something to be
> temporarily deleted (how often is that?) you can still drag it to the Recycle Bin.
> :-)

Very often in y case. But at the time I don't know it will be temporarily.