473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding if a file is less than 24 hours old

Is there a simple way using the File class to see is a file is older
than 24 hours?

Jul 13 '07 #1
3 1524
On Jul 13, 10:16 am, timn...@gmail.c om wrote:
Is there a simple way using the File class to see is a file is older
than 24 hours?
You can use the FileInfo class, something like this:

FileInfo fi = new FileInfo(@"C:\f oo.txt");
DateTime dt = fi.CreationTime ;

Jul 13 '07 #2
Well, you can use the static GetLastAccessTi me, GetLastWriteTim e and
GetCreationTime methods to determine what the last time the file was
accessed, written to, or when it was created. You can then compare those
times to the time in question and see if it is past 24 hours (by subtracting
one of the times returned from those methods from the time in question, and
then seeing if the resulting TimeSpan is greater than 24 hours.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<ti*****@gmail. comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
Is there a simple way using the File class to see is a file is older
than 24 hours?

Jul 13 '07 #3
The FileInfo class has the properties you need to do this.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder( BETA): http://www.blogmetafinder.com

"ti*****@gmail. com" wrote:
Is there a simple way using the File class to see is a file is older
than 24 hours?

Jul 13 '07 #4

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

Similar topics

17
23173
by: Sean Ross | last post by:
Hi. Recently I made a small script to do some file transferring (among other things). I wanted to monitor the progress of the file transfer, so I needed to know the size of the files I was transferring. Finding out how to get this information took some time (reading the manuals - googling did not prove worthwhile). Anyway, I did eventually figure out how to do it (there are a few ways, including os.path.getsize(filename)). My...
6
2112
by: soren juhu | last post by:
Hi, I am developing a C Program for reading over a million files of size 1 kilobytes each and sending the contents to another program using some middle ware. I need some help on designing the program to process such a large number of files in less than 8 hours. TIA Soren
34
2814
by: Ross Reyes | last post by:
HI - Sorry for maybe a too simple a question but I googled and also checked my reference O'Reilly Learning Python book and I did not find a satisfactory answer. When I use readlines, what happens if the number of lines is huge? I have a very big file (4GB) I want to read in, but I'm sure there must be some limitation to readlines and I'd like to know how it is handled by python. I am using it like this:
20
10867
by: Joel Hedlund | last post by:
Hi all! I use python for writing terminal applications and I have been bothered by how hard it seems to be to determine the terminal size. What is the best way of doing this? At the end I've included a code snippet from Chuck Blake 'ls' app in python. It seems to do the job just fine on my comp, but regrettably, I'm not sassy enough to wrap my head around the fine grain details on this one. How cross-platform is this? Is there a more...
13
3219
by: pb648174 | last post by:
Whenever I want help on a query, I get told my design is wrong, So this time I'm posting a message during the design phase: How am I going to perfectly design the following? We want to be able to track time for users for multiple modules, for now a Schedule module and a Punchlist module. These modules already exist and there are dozens of other modules which we will add to the list as well, two or three at a time - so it should be...
16
7189
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain unchanged). How can I do that in Python? Claudio Grondi
8
1646
by: n30810c377 | last post by:
I am not very good in C++, however I have this task and I really need your help here. I am using Borland C++ 4.51 compiler. I am stuck, and I dont have any lead to do this.. Here is the thing: The following data are obtained from the file ‘klwea.txt’. It contains the twenty-four hourly average air temperatures for the months of January through December, recorded at KLIA airport. 23.0 22.7 23.7 23.9 24.1 24.9 23.9 23.7 23.9 23.9 24.2 23.7...
10
1584
by: Redhairs | last post by:
In a web farm environment, how to store the user uploading files for future access? Store them in db, local file system or centralized file server? If trying to storing the file in local file system or centralized file server, how the web server receives the uploading file and sync to each web server's local file system? or the centralized file server?
0
1976
by: Filemaxor | last post by:
I have gotten my code to be able to allow people to add new text to a .txt document and able to call up files so the user can see whats in it. The problem i'm having is getting the for loop to work correctly so that i can allow certain indexes to be removed without completely deleting everything else. This is what i have so far. Code is below It's in the e part of the code and I have //remed the location of the for loop containg the...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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,...
0
9953
tracyyun
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...
0
8978
agi2029
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...
1
7502
isladogs
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...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.