Saving formatted timestring as file name problem in c# -
hi guys, started c# i'm not 100% familiar it's syntax yet , got problem. i'd write current time filename. i'm using following code:
datetime = datetime.now; string datestring = string.format(@"z:\test\{0}.bmp",now.tostring("s")); bitmap.save(datestring);
now gives me can't access filepath error. apparently has ":" characters @ time part (at least when give now.tostring("d") ) saves fine. idea whats causing this? thanks.
the "s" format create filename of like:
2009-06-15t13:45:30.bmp
that's not valid filename, due colon. either replace colon character after calling tostring, or use different format.
note "d" won't work either, can include "/" in name, depending on culture.
personally i'd suggest "yyyymmdd-hhmmss" give like
20090615-134530.bmp
Comments
Post a Comment