CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    158

    [RESOLVED] Adding date to file name.

    This has become a major headache for me.

    I am simply trying to add the days date to a filename.

    Code:
    FilePathStr = Environment.CurrentDirectory() & "\Data\Data Archive\Padding " & Mydate & ".txt"
    'Mydate' is a string made up of datetime.now.day/month/year.
    I have also tried inserting , now and today
    If I add just one instance of datetime.now.day it works, anymore gives me a DirectoryNotFoundException)

    This is really confusing, any help appreciated.
    Last edited by dajunka; May 29th, 2010 at 03:42 AM. Reason: RESOLVED
    I use VB.Net 2008 in all my wash, for those whiter whites.

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Adding date to file name.

    Most likely it reads your new file name as directory path if you include characters like / or \ in your date string. Try making your date string with - instead.

  3. #3
    Join Date
    Apr 2004
    Posts
    158

    Re: Adding date to file name.

    Oh my word, I would not have found that in a million years.

    Thanks very much, just changed the little blighter's "/" for "_" and Bobs your uncle. How could something so simple give me more than a days worth of headaches?
    I use VB.Net 2008 in all my wash, for those whiter whites.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Adding date to file name.

    Operating System liek Windows XP etc. do not allow / or \ in file names, I tend to use _ with date values in names

    Just remember to mark your thread resolved

    http://www.codeguru.com/forum/showthread.php?t=403073

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured