小问题? [英] Small question?

查看:67
本文介绍了小问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我差不多完成了我的小工作申请。这个周末我已经在Streams上工作了,所以我可以编写一个日志文件来显示完成的工作。想要以编程方式使每个日志文件都是唯一的,我/ b
决定将日志写入的日期包括在内,即

文件名。我正在查看所有日期内容和所有帖子

关于格式化,并想知道在世界上我将如何获得所有

我想要的方式。我正在寻找一种方法来格式化JUST

日期并进入''DateString''方法。它给了我我正是在寻找没有大量额外工作的
,但我想知道......而且这里的问题是... b $ b问题...是这种方法有些不合格吗?在

新闻组中,我看到人们想要约会,并且答案已经

在格式化方面确实非常强大,而DateString并不需要。

I''ve almost completed my little application for work. This weekend I''ve been
working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmatically unique, I
decided to include the date that the log was written as a part of it''s
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format JUST
the date and ran into the ''DateString'' method. It gave me exactly what I was
looking for without a lot of extra work, but I was wondering... and here''s
the question... is there something substandard with this method? In the
newsgroup here I''ve seen folks wanting JUST a date and the answers have
really been strong on formatting, which the DateString doesn''t require.

推荐答案

" Bruce W. Darby" < kr **** @ comcast.netwrote在

新闻:ZI *************************** ***@comcast.com:
"Bruce W. Darby" <kr****@comcast.netwrote in
news:ZI******************************@comcast.com:

我几乎完成了我的小工作申请。本周末

我一直在使用Streams,所以我可以编写一个日志文件来显示已经完成的工作


I''ve almost completed my little application for work. This weekend
I''ve been working on Streams so I can write a logfile showing the work
that was accomplished.



您是否看过Log4Net或Microsoft的Enterprise日志记录块?

Have you taken a look at Log4Net or Microsoft''s Enterprise logging blocks?


>我看到人们想要约会,而答案确实是
>I''ve seen folks wanting JUST a date and the answers have really been



格式化很强,DateString没有要求。

strong on formatting, which the DateString doesn''t require.



多么漫无边际的帖子 - 你现在看看()。ShortDate?那个

将日期格式化为本地区域设置。


否则你可以使用FormatDateTime命令指定你自己的格式。

What a rambling post - have you taken a look at now().ShortDate? That
formats the date to the local regional settings.

Otherwise you can use the FormatDateTime command specify your own format.


布鲁斯,


我不知道这个功能。不是很奇怪:如果我理解得很好,那么它在美国以外就完全没用了。


在我的想法中,这个建筑最适合你的目的


Dim mylogfiledate As String = Now.ToString(" yyyyMMddhhmmss")

我希望这会有所帮助,


Cor


" Bruce W. Darby" < kr **** @ comcast.netschreef在bericht

新闻:ZI ************************** ****@comcast.com。 ..
Bruce,

I did not knew this function. Not so strange:. if I understand it well, than
it is outside the USA completely useless.

In my idea is this construction beneath the nicest for your purpose

Dim mylogfiledate As String = Now.ToString("yyyyMMddhhmmss")
I hope this helps,

Cor

"Bruce W. Darby" <kr****@comcast.netschreef in bericht
news:ZI******************************@comcast.com. ..

我几乎完成了我的小工作申请。本周末我已经在Streams上工作了,所以我可以编写一个日志文件,显示完成的工作是完成的。想要以编程方式使每个日志文件都是唯一的,我/ b
决定将日志写入的日期包括在内,即

文件名。我正在查看所有日期内容和所有帖子

关于格式化,并想知道在世界上我将如何获得所有

我想要的方式。我正在寻找一种格式化方式

JUST日期并进入''DateString''方法。它给了我确切的

我正在寻找的没有太多额外的工作,但我想知道......

这里的问题是...这个

方法有什么不合标准的吗?在这里的新闻组中,我看到人们想要约会,并且

答案在格式化方面确实非常强大,而DateString

并不需要。
I''ve almost completed my little application for work. This weekend I''ve
been working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmatically unique, I
decided to include the date that the log was written as a part of it''s
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format
JUST the date and ran into the ''DateString'' method. It gave me exactly
what I was looking for without a lot of extra work, but I was wondering...
and here''s the question... is there something substandard with this
method? In the newsgroup here I''ve seen folks wanting JUST a date and the
answers have really been strong on formatting, which the DateString
doesn''t require.



你需要记住的第一件事,Bruce,就是DateString

函数没有返回日期。 Instaed它返回一个表示

的字符串当前日期格式为MM-dd-yyyy。


这是与

DateTime.Today.ToString(" MM-dd-yyyy")以及

DateTime.Now.ToString(" MM-dd-yyyy")。如果您的区域短日期设置为

设置为MM-dd-yyyy,那么

DateTime.Today.ToString(" d")也会返回相同的值。 DateTime.Now.ToString(" d")。


如果您需要的只是MM-dd-yyyy fomat中的日期那么好,但是

多种日期格式选项为您提供了更多选项。


至于日志文件,您需要问自己的问题包括:


1.程序每次运行时都会写一个新的日志文件吗?


2.程序会在任何一天运行多次吗?

3.除了我以外的其他人是否需要访问日志文件?


如果(1)为真且(2)为真,那么你''重新遇到问题

,因为当天的后续运行将覆盖当日运行的
日志文件。


如果(3)为真,则为日志文件的命名约定必须是这样的,他们明白地知道他们正在看什么,即当

文件被命名为01-02-2007.log时,他们必须是绝对意识到文件

与1月2日而不是2月1日有关。


我广泛使用日志文件,不仅记录关键活动,还有

诊断信息。


当我每天使用新的日志文件时,我使用的命名约定是

yyyyMMdd.log并且每个必须处理此类文件的人都知道

名称是那种格式。


当我使用新的时候每个月的日志文件,我使用的命名约定

是yyyyMM.log,而且,每个必须处理此类文件的人都知道

该名称所在的那个格式。


最重要的是与你的工作完全一致。如果

你砍掉并改变那么你最终会让自己感到困惑。

" Bruce W. Darby" < kr **** @ comcast.netwrote in message

新闻:ZI ************************** ****@comcast.com。 ..
The first thing that you need to remember, Bruce, is that the DateString
function does not return a Date. Instaed it returns a string that represents
the current Date formatted as MM-dd-yyyy.

This is the same value that is returned by
DateTime.Today.ToString("MM-dd-yyyy") and also
DateTime.Now.ToString("MM-dd-yyyy"). If your Regional Short Date setting is
set to MM-dd-yyyy then the same value is also returned by
DateTime.Today.ToString("d") and DateTime.Now.ToString("d").

If all you will ever need is the date in MM-dd-yyyy fomat then fine, but the
multitude of date formatting options provides you with so many more options.

As to log files, the questions you need to ask yourself include:

1. Will the program write a new logfile each time it runs?

2. Will the program run multiple times in any one day?

3. Will the log files need to be accessed by anyone else apart from me?

If (1) is true and (2) is true then you''re going to run into problems
because subsequent runs in the same day will overwrite the log files from
previous runs on that day.

If (3) is true then the naming convention for the log files must be such
that they know, unambiguously, what it is they are looking at, i.e. when the
file is named 01-02-2007.log, they must be absolutely aware that the file
relates to the 2nd of January and not the 1st of February.

I use log files extensively, not only to log critical activity, but also for
diagnostic information.

When I am using a new log file for each day, the naming convention I use is
yyyyMMdd.log and everybody who has to deal with such file knows that the
name is in that format.

When I am using a new log file for each month, the naming convention I use
is yyyyMM.log and, again, everybody who has to deal with such file knows
that the name is in that format.

The most important thing is to be absolutely consistent with what you do. If
you chop and change then you will end up confusing yourself.
"Bruce W. Darby" <kr****@comcast.netwrote in message
news:ZI******************************@comcast.com. ..

我几乎完成了我的小工作申请。本周末我已经在Streams上工作了,所以我可以编写一个日志文件,显示完成的工作是完成的。想要以编程方式使每个日志文件都是唯一的,我/ b
决定将日志写入的日期包括在内,即

文件名。我正在查看所有日期内容和所有帖子

关于格式化,并想知道在世界上我将如何获得所有

我想要的方式。我正在寻找一种格式化方式

JUST日期并进入''DateString''方法。它给了我确切的

我正在寻找的没有太多额外的工作,但我想知道......

这里的问题是...这个

方法有什么不合标准的吗?在这里的新闻组中,我看到人们想要约会,并且

答案在格式化方面确实非常强大,而DateString

并不需要。
I''ve almost completed my little application for work. This weekend I''ve
been working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmatically unique, I
decided to include the date that the log was written as a part of it''s
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format
JUST the date and ran into the ''DateString'' method. It gave me exactly
what I was looking for without a lot of extra work, but I was wondering...
and here''s the question... is there something substandard with this
method? In the newsgroup here I''ve seen folks wanting JUST a date and the
answers have really been strong on formatting, which the DateString
doesn''t require.



这篇关于小问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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