Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Better Code (http://www.programmingforums.org/showthread.php?t=11120)

NightShade01 Aug 19th, 2006 10:34 PM

Better Code
 
I'm writing a small app that's only task is to search for the windows prefetch folder and delete all that's in it. now this can be done by searching and just deleting the entire directory (it will re create itself) or you can search and then write a do...while loop to delete individual things within it. Which way is more acceptable/practical? or does is not matter?

King Aug 19th, 2006 10:41 PM

It probably does not really matter; I would just delete the directory itself. The prefetch folder will just re-create itself, so there is no point in taking extra cycles to go in and delete the individual files.

AntiNinja Aug 19th, 2006 10:43 PM

:

cd /d %WINDIR%\Prefetch\
del /q *.*

That's what I would do, its easy, quick and gets the job done, plain and simple.

King Aug 19th, 2006 10:50 PM

NightShade01, if you are writing this program to learn how do manage files then go for it, but if you are writing this to make things easier for yourself, I would probably do what AntiNinja posted.

NightShade01 Aug 20th, 2006 12:42 AM

I am writing this little app as part of a larger project however i know what AntiNinja is talking about (batch fiiling) and i can just incorporate that into my code. I was just wondering if one was better programming Etiquette

King Aug 20th, 2006 2:06 AM

As far as programming etiquette goes, they are both fine in this case. If the prefetch folder didn't regenerate automatically, it would be a bad idea to just delete the whole folder, but it does, so it would be more efficient programmatically to just delete the whole thing at once.

Ooble Aug 20th, 2006 3:26 PM

It's generally a bad idea to nuke your Prefetch folder. Windows uses the folder to store information on program loading so the application will load faster the next time. You may be saving a miniscule amount of disk space, but you're wasting your own time by deleting the folder. With hard drive prices so damn low, there's really no reason to delete it.

King Aug 20th, 2006 4:01 PM

Ooble, I don't think it's that bad of an idea to delete the Prefetch folder once in a while. It gets filled with a bunch of crap, especially if you have changed what process get started on boot up. So deleting it once in a while and having windows regenerate it is a good idea because it cleans out a bunch of useless crap, and windows will put only what it needs back in. But you are right; doing this will save very little disk space and will probably have very little performance gain.

Ooble Aug 20th, 2006 4:21 PM

My point is that it will have negative performance gain. You're right - some programs will not exist any more, or will be applications you don't use, but the majority will be very useful.

King Aug 20th, 2006 4:47 PM

When Windows reboots and sees that it is not there, it will re-create it and put the nessisary files back in. So the first boot when it's not there will be slower, but after that it will be back up to speed, with a lot less crap in the folder.


All times are GMT -5. The time now is 12:41 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC