PDA

View Full Version : use current date to rename a file


yhb
11-22-2007, 04:28 AM
Need some help again, :) How would I rename a file to the current date and time it was renamed?

Example:

date = current date (ex. 11272007)
time = current time (ex. 0325AM)

File.Rename("C:\\Temp\\filename.txt", "C:\\Temp\\filename_date_time.txt");

So, the new file name will look like below:

filename_11272007_0325AM.txt

Anybody?

Thanks in advanced... :)

yhb)

yosik
11-22-2007, 04:35 AM
Simple enough:

date = current date (ex. 11272007)
time = current time (ex. 0325AM)

File.Rename("C:\\Temp\\filename.txt", "C:\\Temp\\filename_"..date.."_"..time..".txt");

Good luck
Yossi

yhb
11-22-2007, 04:46 AM
but isn't that only will picked up what i have in my date and time? not the actual date and time it was renamed? :(

yhb)

yosik
11-22-2007, 05:00 AM
If you use the System.GetTime and System.GetDate actions, you are getting these values in realtime. Then when you rename the file , using your variables, the file will be renamed accordingly.

Yossi

yhb
11-22-2007, 05:19 AM
I got your point... :) Thanks much...

yhb)