when close c# window, hope append timestamp filename. however, when run following codes, got such error:
'system.notsupportedexception'
and
"the given path's format not supported.".
is there method modify parameters?
private void window_closed(object sender, eventargs e) { sw_bea.close(); string file_time = datetime.now.tostring("h:mm:ss tt").tostring(); system.io.file.move(@"c:\users\abc\desktop\tmp_bea.txt", @"c:\users\abc\desktop\tmp_bea"+file_time+".txt"); }
as have commented, proximate problem colons in filename.
in general, if want ensure filename doesn't contain illegal characters, can like
for (char c in path.getinvalidfilenamechars()) filename=filename.replace(c, '_');
Comments
Post a Comment