473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

everyday a new file?

Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the date as
name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866
Nov 15 '05 #1
6 2988
Sorry because the date....I changed it back....

"Dirk Reske" <_F*******@gmx.net> schrieb im Newsbeitrag
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the date as name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866

Nov 15 '05 #2
Dirk,

How do you log the events? I'm assuming that you have one API call (or
a limited handful) which manages how the log file is opened, and then
written to.

All you have to do when you make the call is check the filename of the
file stream you have open (if you keep it open all the time). If it doesn't
match with the time the call is made, then close it and open a new one.

You can get the filename by calling the ToString method on the current
DateTime, passing the following format:

yyyyMMdd

This will also have the effect of making the files sortable by date.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the date as name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866

Nov 15 '05 #3
when I create the File I set the global DateTime variable FileCreateDate to
the aktuall date.

before I write to the file I check the date:

if (this.FileCreateDate.Date < DateTime.Today.Date)
//create new file
else
//write to the open File

but this doesn't work, if I have a new day

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:eJ**************@TK2MSFTNGP09.phx.gbl...
Dirk,

How do you log the events? I'm assuming that you have one API call (or a limited handful) which manages how the log file is opened, and then
written to.

All you have to do when you make the call is check the filename of the
file stream you have open (if you keep it open all the time). If it doesn't match with the time the call is made, then close it and open a new one.

You can get the filename by calling the ToString method on the current
DateTime, passing the following format:

yyyyMMdd

This will also have the effect of making the files sortable by date.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the
date as
name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866


Nov 15 '05 #4
Dirk,

if (this.FileCreateDate.Date < DateTime.Today.Date)
//create new file
else
//write to the open File


It shouldn't be that complicated. Try something like:
FileStream fs = new FileStream(DateTime.Now.ToString("yyyyMMdd")+".log ",
FileMode.OpenOrCreate);
By using FileMode.OpenOrCreate the file will open the file or create the
file it it does not exist.
Good luck
Brian W


Nov 15 '05 #5
How about just using log4Net. They have already built this functionality
and much more.

--
Greg Ewing [MVP]
http://www.citidc.com

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the date as name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866

Nov 15 '05 #6
Try using the CompareTo method on DateTime or use a TimeSpan

Nick

"Dirk Reske" <_F*******@gmx.net> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hello,

I write an app that, logs events.
how can I make, that everyday a new file whould be createt, with the date as name?

thx

--
----------------------------------------------------
I'm from Germany, so excuse my english :-)
ICQ: 97255866

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
0
by: Shireesha | last post by:
Hi all, I am new to this group and wish clear some doubts regarding tomcat server and database connection pooling (Java language). Our group has developed a application using Tomcat 4.x. We need...
3
by: pri10der | last post by:
Can somone explain me how to run some procedure everyday at 22:00 in MSSQL. This is not an Administrative Task, it's my procedure.
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
7
by: sachu | last post by:
Hi, Is there is way to run a php file perodically everyday on scheduled time in such a way that there is no human interaction and it performence the written task.
9
by: LimaCharlie | last post by:
Good Day to all, Hope you could help me w/ my project. Im creating a DTS Package. The source data will be coming from an excel file going to my SQL table. The DTS package is scheduled to execute...
3
by: Riun | last post by:
Hi I need to import excel sheet to access - the sheets are stored everyday with the same name, but with the day's date at the end of the name to distinguish them. What code can one use to import...
0
by: james | last post by:
Want more persons to visit your site everyday? Add traffic to your sites. Add the CTR ratio and eCPM by posting on various classifieds, just spend five minutes to increase your earning, for details...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.