Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 19th, 2006, 10:34 PM   #1
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
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?
NightShade01 is offline   Reply With Quote
Old Aug 19th, 2006, 10:41 PM   #2
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
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.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Aug 19th, 2006, 10:43 PM   #3
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
cd /d %WINDIR%\Prefetch\
del /q *.*
That's what I would do, its easy, quick and gets the job done, plain and simple.
__________________
Pain is just weakness leaving the body.
AntiNinja is offline   Reply With Quote
Old Aug 19th, 2006, 10:50 PM   #4
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
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.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Aug 20th, 2006, 12:42 AM   #5
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
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
NightShade01 is offline   Reply With Quote
Old Aug 20th, 2006, 2:06 AM   #6
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
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.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Aug 20th, 2006, 3:26 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 20th, 2006, 4:01 PM   #8
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
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.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Aug 20th, 2006, 4:21 PM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 20th, 2006, 4:47 PM   #10
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
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.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EXECryptor software protection Jean5 C++ 35 Oct 10th, 2006 8:10 PM
Little help whoawhoayoyo Assembly 8 Apr 18th, 2006 8:10 PM
How to post a question nnxion C++ 10 Jun 3rd, 2005 12:53 PM
How to post a question nnxion C++ 0 Jun 3rd, 2005 9:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 9:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:25 PM.

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