473,320 Members | 2,107 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,320 software developers and data experts.

Any way to clear old log files

Hi I have a console application C# VS2005 that runs remotely and creates a
timestamped log file each time it runs (nightly). I was just wondering if
there is a way to delete only files that are more than 30 days old?
Thanks.
--
Paul G
Software engineer.
Aug 12 '08 #1
2 1141
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:74**********************************@microsof t.com...
Hi I have a console application C# VS2005 that runs remotely and creates a
timestamped log file each time it runs (nightly). I was just wondering if
there is a way to delete only files that are more than 30 days old?
Point the GetFiles method of the DirectoryInfo class at the folder where the
log files are stored.

Read each file into a FileInfo object and inspect its LastWriteTime
property.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 12 '08 #2
Thanks it worked!
--
Paul G
Software engineer.
"Mark Rae [MVP]" wrote:
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:74**********************************@microsof t.com...
Hi I have a console application C# VS2005 that runs remotely and creates a
timestamped log file each time it runs (nightly). I was just wondering if
there is a way to delete only files that are more than 30 days old?

Point the GetFiles method of the DirectoryInfo class at the folder where the
log files are stored.

Read each file into a FileInfo object and inspect its LastWriteTime
property.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 13 '08 #3

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

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
18
by: Tim Mierzejewski | last post by:
How do I clear the text from my screen, other than a bunch of \n's or endl's? Tim M.
12
by: Gaurav | last post by:
Hello I have a program that basically inverts the contents of files except first line. It compiles fine but gives me core dump on running. If i comment temp.clear() it runs fine, but i need...
1
by: Ruskin | last post by:
I have a wee issue, where I have two different web sites; http://dev/home.htm http://live/home.htm On both sites, there is a custom OCX file being used. However, it may be a different version...
1
by: davidgordon | last post by:
Hi, I have a form with 2 combo boxes. I am not using them in the usual way, please read on: In the 'Form Load' event, I have: _______________________________________ dim folderspec as...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
0
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or...
22
by: mp | last post by:
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none...
9
by: silversurfer | last post by:
Hello world, I was just wondering why the clear-line in my Makefile does not work: main:main.o $(ADDOBJS) clear @g++ -o main $(LDFLAGS) $+ As far as I understood it, it should be possible to...
4
by: matt | last post by:
hello, so from time to time i have to write code to send a file or a stream back to the end user. in my mini library i have code to do so. however, some of the Response object properties arent...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.