Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,155 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,116 people online right now. Registration is fast and FREE... Join Now!




systems programming

 
Reply to this topicStart new topic

systems programming, compare timestamps of files

marcbachman
10 Dec, 2007 - 09:41 AM
Post #1

New D.I.C Head
*

Joined: 10 Dec, 2007
Posts: 3


My Contributions
Hello-
I would like to propose my idea and request comments, here's the problem:
I need to compare the timestamp ( date modified attribute ) of each file in one directory to the timestamp of its corresponding sibling file in another directory. Since the filenames are dissimilar, I can't easily code a search using regexp, I guess I'll just have to handcode a mapping of the file relationship in another text file that I will have to read in. So, I'm thinking once I have the one-to-one relationship read in and a two file objects declared with their timestamp attributes, in a loop 'll just have to compare the timestamps, and if they're not the same, pipe a message out to another text file naming the file whose timestamp did not match. This will need to run on Windows ( server, preferably ) so, barring a better alternative, I guess I'll use C#. So how do I get the value for timestamp into file.timestamp property? I will be using VS 2005 to code, unless I would be better off with a categorically different approach
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Systems Programming
10 Dec, 2007 - 10:54 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
I had you all the way up until you said put the timestamp into file.timestamp property. Are you looking to modify file timestamps? Like if they are not the same, to then synchronize them by modifying a file timestamp? You had the right idea right up until that part about modifying the timestamp. Can you clarify?

Thanks! smile.gif

This post has been edited by Martyr2: 10 Dec, 2007 - 10:54 AM
User is online!Profile CardPM
+Quote Post

marcbachman
RE: Systems Programming
10 Dec, 2007 - 11:45 AM
Post #3

New D.I.C Head
*

Joined: 10 Dec, 2007
Posts: 3


My Contributions
QUOTE(Martyr2 @ 10 Dec, 2007 - 11:54 AM) *

I had you all the way up until you said put the timestamp into file.timestamp property. Are you looking to modify file timestamps? Like if they are not the same, to then synchronize them by modifying a file timestamp? You had the right idea right up until that part about modifying the timestamp. Can you clarify?

Thanks! smile.gif

Sorry, I tend to be a little wordy naturally, but left out the important part: I'm comparing the timestamps on files between two directories, directoryA is the original file, directoryB has clones of the directoryA files which are "backups". Timestamps on the directoryA files will always be very close to or newer than timestamps on the corresponding directoryB files ( unless they weren't manually backed up, which ultimately becomes my job ). The purpose of the application is to determine which of the directoryB ( backup ) file timestamps are significantly earlier than the timestamps on the corresponding directoryA file. When I say timestamp, I'm presuming a string value which I'll parse into a .timestamp property to compare month/day/year. I wouldn't want to modify the timestamps with this application, just compare.
User is offlineProfile CardPM
+Quote Post

ericode
RE: Systems Programming
16 Dec, 2007 - 06:48 PM
Post #4

D.I.C Head
Group Icon

Joined: 9 Dec, 2006
Posts: 89


Dream Kudos: 75
My Contributions
This can be used to find the last time a file was written to.
public static DateTime GetLastWriteTime ( string path )

Why can't the backup's have the same name as the original files, if they are in different directories? It seems like that would make it easier.

This post has been edited by ericode: 16 Dec, 2007 - 06:49 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 11:17PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month