file copying

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dipalichavan82
    New Member
    • Feb 2008
    • 41

    file copying

    i want to copy a file name C:\\log.text to C:\\ in format of:
    C:\\ username-logfile-datetime.txt
    yymm & usrname are my global variable

    i did:


    FileInfo logfile = new FileInfo("C:\\l og.txt");
    string LFile = "C:\\"+GlobVar. UsrName+"-LogFile-"+GlobVar.YYMM+ DateTime.Now.To ShortTimeString ()+".txt";

    logfile.CopyTo( LFile, true);

    i am getting error:
    "The given path's format is not supported."
    i think problem is due to "DateTime.Now.T oShortTimeStrin g()"
    please help me : what sort of error this is.please help
    Last edited by dipalichavan82; Feb 19 '08, 02:01 PM. Reason: want to add more info
  • dipalichavan82
    New Member
    • Feb 2008
    • 41

    #2
    hey , i got the answer.
    when i m asking for current time, it is in this format(3:34)
    and we cant use reserved char like :,? for file name.
    sloution is take current time in string and replace : by - or any other allowed char

    Comment

    Working...