Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Folks, I'm doing an error log in my code and I'm trying to output the errors to a text file with a specific date/time in the title so they can differentiate.
I've tried things like

VB
logname = "C:\Documents and Settings\SeDing\Desktop\Errors\errorsLog\ " & DateTime.Now.ToString() & ".log\"


But i get this msg "The given path's format is not supported." all the time.

Any ideas?? I'm quite a noob. Thx.

[edit]pre tag for VB code added - PES [/edit]
Posted
Updated 7-Mar-12 5:36am
v2

Well, have you tried doing just DateTime.Now.ToString() to see what it output?? Chances are good that it's using "/" characters. That character is illegal in a filename.

Do something more like
logname = DateTime.Now().ToString("ddMMyyyyHHmmss") & ".log"
 
Share this answer
 
logName = String.Format("C:\Documents and Settings\SeDing\Desktop\Errors\{0}.log", DateTime.Now.ToString("yyyyMMddhhmmss"))


this worked for me.
Thanks man.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900