use current date to rename a file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • yhb
    Forum Member
    • Sep 2007
    • 74

    use current date to rename a file

    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
    Indigo Rose Customer
    • Jun 2002
    • 1858

    #2
    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

    Comment

    • yhb
      Forum Member
      • Sep 2007
      • 74

      #3
      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)

      Comment

      • yosik
        Indigo Rose Customer
        • Jun 2002
        • 1858

        #4
        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

        Comment

        • yhb
          Forum Member
          • Sep 2007
          • 74

          #5
          I got your point... Thanks much...

          yhb)

          Comment

          Working...
          X