Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This logic is working but...I want it to remove a file that is 20 seconds or less, I'm getting "Delete" on very new files, but I don't think its 20 seconds, no idea what it is now.............

C++
age = curTime - fileTime;
if (age <= (_int64)curTime/10000000UL-20)
{
wcout << "Delete:" <<endl;
}
else
{
wcout << "Quit;" <<endl;
}

Thank You.
Posted
Updated 2-Oct-11 22:29pm
v6
Comments
Simon Bang Terkildsen 3-Oct-11 4:09am    
Removed pre tags after adding them, due to Richard's post.
walterhevedeich 3-Oct-11 4:13am    
I was about to edit it before I noticed your comment. :)
Member 7766180 3-Oct-11 4:28am    
Something was wrong and I couldn't put the tags in. The code was half disappering. Sorry.
Stefan_Lang 3-Oct-11 4:30am    
Insufficient information error
age: symbol or type unknown
curtime: symbol or type unknown
fileTime: symbol or type unknown
wcout: symbol or type unknown

Output analysis error: unable to debug source code. Source code not found.
Member 7766180 3-Oct-11 4:32am    
Stefan, look below Richards solution, please. Thank you.

1 solution

1. Please use <pre> tags around your code; you've posted enough questions to know this.
2. Explain exactly what you are trying to calculate and why the answer is wrong; show the values of different variables.
3. Learn to use your debugger.
 
Share this answer
 
Comments
Member 7766180 3-Oct-11 4:18am    
Richard, I tried to but it was acting weird and half the code was missing. Tried like 10 times!
Member 7766180 3-Oct-11 4:20am    
Here is the output I am getting...
Found 9 matching files.
Quit: '
FILE: '2.txt', AGE: 91217 seconds
Quit: '
FILE: 'devil.txt', AGE: 2740 seconds
Quit: '
FILE: 'dog.txt', AGE: 32107 seconds
Quit: '
FILE: 'giant.txt', AGE: 32183 seconds
Delete: '
FILE: 'head.txt', AGE: 316 seconds
Quit: '
FILE: 'heston.txt', AGE: 5224 seconds
Delete: '
FILE: 'norman.txt', AGE: 506 seconds
Quit: '
FILE: 'ONEWAY.txt', AGE: 36764 seconds
Quit: '
FILE: 'sj.txt', AGE: 19838 seconds
Press any key to continue . . .
Member 7766180 3-Oct-11 4:21am    
The Values...
curTime = ((_int64) ftNow.dwHighDateTime << 32) + ftNow.dwLowDateTime;
fileTime = ((_int64)iter->ftLastWriteTime.dwHighDateTime << 32) + iter->ftLastWriteTime.dwLowDateTime;
unsigned _int64 fileTime, curTime, age;
Richard MacCutchan 3-Oct-11 4:32am    
These are not values, these are lines of code! What are the actual values of your variables at the time you make the comparison between the two times. As I said above, learn to use your debugger and please stop posting new versions of what is essentially the same question.
Member 7766180 3-Oct-11 4:36am    
unsigned _int64 fileTime, curTime, age; Sorry Richard this is the last piece I need to do, deleting files that are less than 20 seconds. After this I am going to college and take a course, won't be posting for awhile after this, I just need to finish this last piece for myself. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900