如何在生成的Filestream文本文件的标题中包括日期/时间? [英] How do I include date/time in the title of Filestream text file I'm generating?

查看:93
本文介绍了如何在生成的Filestream文本文件的标题中包括日期/时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我正在代码中记录错误,并且尝试将错误输出到标题中具有特定日期/时间的文本文件中,以便于区分.
我尝试过类似
的事情

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

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



但是我得到此消息不支持给定路径的格式."一直这样.

有任何想法吗??我真是个菜鸟.谢谢.

为VB代码添加了[edit] pre标签-PES [/edit]



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]

推荐答案

好吧,您是否尝试过仅做DateTime.Now.ToString()来查看它输出??很有可能使用"/"字符.该字符在文件名中是非法的.

做更多类似
的事情
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"


logName = String.Format("C:\ Documents and Settings \ SeDing \ Desktop \ Errors \ {0} .log",DateTime.Now.ToString("yyyyMMddhhmmss" ))


这对我有用.
谢谢你.
logName = String.Format("C:\Documents and Settings\SeDing\Desktop\Errors\{0}.log", DateTime.Now.ToString("yyyyMMddhhmmss"))


this worked for me.
Thanks man.


这篇关于如何在生成的Filestream文本文件的标题中包括日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆