[RESOLVED] Adding date to file name.
This has become a major headache for me. :sick:
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.
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.
Re: Adding date to file name.
Oh my word, I would not have found that in a million years. :blush:
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? :D
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