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 6 3001
Sorry because the date....I changed it back....
"Dirk Reske" <_F*******@gmx. net> schrieb im Newsbeitrag
news:uI******** ******@TK2MSFTN GP11.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
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.co m
"Dirk Reske" <_F*******@gmx. net> wrote in message
news:uI******** ******@TK2MSFTN GP11.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
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.FileCreat eDate.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.c om> schrieb
im Newsbeitrag news:eJ******** ******@TK2MSFTN GP09.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.co m
"Dirk Reske" <_F*******@gmx. net> wrote in message news:uI******** ******@TK2MSFTN GP11.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
Dirk, if (this.FileCreat eDate.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(Date Time.Now.ToStri ng("yyyyMMdd")+ ".log",
FileMode.OpenOr Create);
By using FileMode.OpenOr Create the file will open the file or create the
file it it does not exist.
Good luck
Brian W
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******** ******@TK2MSFTN GP11.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
Try using the CompareTo method on DateTime or use a TimeSpan
Nick
"Dirk Reske" <_F*******@gmx. net> wrote in message
news:uI******** ******@TK2MSFTN GP11.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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 them a
caption, storing the caption and filename in a text file. It's a bit
buggy when removing the photos and captions from the file, and also in
displaying them on the delete page. you can see it in action at
www.4am.com.au/gallery/upload.php...
|
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.
I want to develop a webpage where people can send attachments that are
stored on their local PC.
|
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 to restart the
tomcat everyday and we are unable to know whether it is because of the
connection pooling or from the tomcat server is having the problem
internally. We implemented the connection pooling mechanism from the
following link
|
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.
|
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. How do i make the
last pointer in the indirect sector that has another level of indirect
pointer, and be defined recursively to support infinite large files?
-code-
| |
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.
|
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 daily, but the source data will be coming from different excel filename.
Example, today the DTS will get data from Data092506.xls. Then tomorrow, the data will be coming from Data092606.xls.
How can I do this? The DTS I've already done has a fixed...
|
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 the sheets automatically? at this stage I use the code:
DoCmd.TransferSpreadsheet acImport, , "Tbl Facility", "D:\My Documents\Facility Types.xls", True
it works, but if there is a date at the end of the name that changes everyday, how does...
|
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 :
http://glamourpriya.blogspot.com
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |