Compare file modified date time to system date time

I have an client application that uploads a zip file to a server. Once the server application sees the file, it processes the file. The process starts before the zip file is completely downloaded to the server. I want to delay the process until the file is completely downloaded. I am trying to compare the zip file modified date time with the system date time. If the zip file modified date time is 5 seconds older than the system date time then I know the zip file downloaded. At this point I will continue to process the zip file. I am not sure how I can compare the two date time. The DateTime.Now returns a date with the following format: 6/6/2007. The time is not included. When I check the modified date time for the zip file I get the same format 6/6/2007. When I format both date to mm/dd/yyyy hh:mm:ss AM/PM they become string and I can't compare them. How can I compare to see if the zip file is 5 seconds older than the system date time? Can someone explain how this should be done? I'm using C#.

 Thanks,

 James

0
jlamorte
6/6/2007 1:40:27 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
1101 Views

Similar Articles

[PageSpeed] 34

Something is not right....System.DateTime.Now  always returns down to the seconds.  Show us some code, I don't see why you don't get those information.


Liming Xu
Jumptree ASP.NET 2.0 Project Management - With Source Code, Free to Non Profit Org and Effectively Manage Projects/Tasks/Milestones
0
Liming
6/6/2007 2:48:25 PM

 

I'm checking to see if the File is 5 seconds older than the system date time. My code is below. 

DateTime now = DateTime.Now;

 

if (File.GetCreationTime(FilePath).AddSeconds(90) >now )

{

...

}

0
jlamorte
6/6/2007 3:08:13 PM

I found the solution. I did not compare the  system and file date time since the date time didn't change while the file is downloading. I assign the file size to two variables with a delay between the two variable assignment then compare the two. here's the code.

FileInfo fi = new FileInfo(FilePath);

 

long fileSize=0; //file size

long newSize = 0;//refresh file size

 

fileSize = fi.Length;

Thread.Sleep(10000); //10 second delay for fileSize and newSize is different

fi.Refresh();//refresh file info.

newSize=fi.Length;

while (fileSize != newSize)

{

fileSize = fi.Length;

Thread.Sleep(10000);//10 second delay for fileSize and newSize  difference

fi.Refresh();//refresh file info.

newSize=fi.Length;

}

0
jlamorte
6/6/2007 8:07:23 PM
Reply:

Similar Artilces:

date/time or date and time
I am setting up an SQL database and I will need to get differences in dates. For example I have a start date, start time, completion date and completion time and I want to get the difference between the start and completion. Would it be better to have one field with both date and time in it, or better to have a date field and a time field? Even though I have already started setting up the tables with seperate fields for date and time I am now leaning toward one field with date/time in it. (Only because that is the way I had to do it when setting up an Excel spreadsheet for a similar ta...

java date time and utc date time
hi i have a client written in delphi the backend is written in java (webservice) when fetching a date field from the db, through java to delphi (TXSDateTime class), for some reason the date changes. in the db: 30/07/2009 00:00:00 in delphi: xsdatetime.asdatetime = 29/07/2009 23:00:00 (1 hour before) in delphi xsdatetime.asutcdatetime = 29/07/2009 21:00:00 (3 hours before) i guess it's a matter of timezones but all we want is simply to fetch the same date as it appears in the DB what are we missing? thanks amos szust wrote: > hi > > i have a client written in d...

Date.Compare won't compare dates with times??
Maybe I'm just on crack, but something doesn't seem right here. I'm trying to compare 2 timestamps and it doesn't seem to be working correctly. If I compare only dates without times it works as expected: MessageBox.Show(DateTime.Compare("3/5/04", "3/5/04")) ' returns 0 MessageBox.Show(DateTime.Compare("3/5/04", "3/6/04")) ' returns -1 MessageBox.Show(DateTime.Compare("3/5/04", "3/4/04")) ' returns 1 However, if I include times it doesn't seem to work correctly: MessageBox.Show(DateTime.Compare(CDate("3/5/04 ...

just Time or date portion of a date/time field
Good Day, From a DateTime data column how do I get just a Time portin or just a date portion of data to be displayed. i.e from 11/6/2003 10:03:20 AM I need to display date and time seperately in my data display page. Thanks Regards, In code you could use Dim dt as System.Date Dim day, month, year as integer day = dt.Day month= dt.Month year = dt.Year This also works with DateTime In SQL you could use DATEPART(<datepart>,<datetime>) where <datepart> is the abbreviations mentioned in post 385301 and <datetime> is a...

Changing the system date, time and/or time zone
followup to grc.techtalk Changing the system date, time and/or time zone http://blogs.msdn.com/aaron_margosis/archive/2005/02/11/371474.aspx ----------------------------------------------------------- Quote ----------------------------------------------------------- By default, only Administrators and Power Users can use the ?Date and Time? applet to change the computer's date, time, or time zone. A regular User double-clicking on the clock in the notification area of the taskbar gets only an error message that says, "You do not have the proper privilege level to change...

Adding time for past dates dates or correcting a time entry
Hi all, We are using Bugzilla to record time spent on bugs. Is there a way for a person to add time on a previous date? Or is there a way to correct an entry? I can access the DB by an ODBC connector, but I'm reluctant to change the date in bugs_activity table. Thanks Sanjay On Jul 29, 3:58=A0pm, Sanjay Jain <sanjayjai...@gmail.com> wrote: > Hi all, > > We are using Bugzilla to record time spent on bugs. Is there a way for > a person to add time on a previous date? > > Or is there a way to correct an entry? > > I can access the DB by...

File modified date/time
Is there a way to find the date/time of a file when it was last modified? I want to see if a user has updated a text file using Notepad or Wordpad via my PB app. Thanks in advance. -- David Hepburn, Sydney, Australia. Check out the code in the PFC file services object - even if you're not using PFC you can use the code. You want pfc_n_cst_filesrvwin32.of_getlastwritedatetime() David Hepburn wrote in message <356270A5.58C8CE7B@powerpeople.com.au>... >Is there a way to find the date/time of a file when it was last >modified? I want to see if a user has upd...

Date entered...add time value to make date/time field
Windows XP Professional InfoMaker v 9.0.2 Build 7509 Our database contains a date/time stamp for when a specific activity happens to each shipment. I would like the users to be able to simply enter a date for a specific work day. I need to get a list of shipments where the time of one activity occurred on the entered date prior to 9:20. How can I create a computed field that will basically concatenate/amend the entered date with 9:20 that will later be used for criteria in returning rows? Thanks in advance for any help you can provide! Rita Palazzi Senior Engineer /...

Server Date & Time vs. Local Date & Time
I have the following code (which some members assisted with) and it works great locally... It takes the date and time and formats just the way I want:  e.g.:  10/28/2008 13:58:44 becomes 102820080158 (which is what I want) But, when I upload the app to our server the date pulled is:           10/28/2008 1:59:37 PM As a result the date skips the formatting and does not work, so how can I code this so the date/time will be the same whether its local or on a server, and I have adjusted the regional settings to match - and same issue...

just Time or date portion of date/time field: SOMEBODY PLS
Good Day, From a DateTime data column how do I get just a Time portin or just a date portion of data to be displayed. i.e from 11/6/2003 10:03:20 AM I need to display date and time seperately in my data display page. Thanks Regards, When you pull in a SQL datetime column value into your .NET code, it is usually cast to a .NET DateTime type... something like this: System.DateTime TheDateAndTime = (System.DateTime)someDataReader["MySQLDateColumn"] Then you can use a variety of .NET methods included in the DateTime class to convert to a strin...

Daylight Savings Time and File Date/Time Stamps
We use automated scripts for AutoCAD Lisp routines to compare files on a local workstation's hard drive to the same files located on the server. If the server files are "newer", then we copy them to the workstation. Thus... we have a poor man's setup to "update" workstations when AutoCAD Lisp programming changes/updates are made. When Daylight Savings time ended Saturday night, the server's time changed as expected, but the time stamp on our files created between April and October also changed. All the files created in that time period had a o...

File time & date change every time
Hi, Since some days, I have a curious problem with file time/date on my file server Novell 6.5 (service pack 4). The date/time "last modified" always change. For example, I have a file "last modified" 12 september 2003, 17:40. Each time I verify the Properties with Windows XP pro, this time/date increase !!!. If I copy this file on a local harddisk, the date is fixed on the file copied, but continue to increase on my file server. It create hudge problems for incremental backup !!! Any idea to resolve this strange situation ??? Thanks in advance ! ea...

file time/date stamp compare..
I was wondering how you look at the timedate stamp of a file. I want to check to see if the one on a server is more up to date. Tim Thorson <> wrote: >I was wondering how you look at the timedate stamp of a file. Since you asked in the language group, the answer would be stat(); Had you asked in the nativeapi group the answer would have been FindFirstFile(); ... "Bob Gonder" <none@nowhere.invalid> wrote in message news:34700@forums.codegear.com... > Had you asked in the nativeapi group > the answer would have been FindFirstFile(); Or G...

DATE field to DATE/TIME
Hello, If the field is defined as a DATE and you do: select datefield+1 from mytable Does the ODBC API (actually ASA 9.02 backend) return a field that is DATETIME or a DATE field? It is messing up my compiled application and seems to be coming back as DATETIME. Thank you. -Robert You are correct, the value is being returned as a TIMESTAMP. You can verify this through using the EXPRTYPE() builtin function, as in select exprtype('select datefield+1 from mytable', 1) from dummy which will return TIMESTAMP. Exprtype is documented in the help. You alm...

Web resources about - Compare file modified date time to system date time - asp.net.web-forms

List of varieties of genetically modified maize - Wikipedia, the free encyclopedia
^ Deliberately cultivated tolerance has effects similar to the naturally acquired traits of resistance in pest species, i.e., enhanced capacity ...

Retro Cars - The coolest modified classic cars on the App Store on iTunes
Get Retro Cars - The coolest modified classic cars on the App Store. See screenshots and ratings, and read customer reviews.

All sizes - Modified Photo: "Starry sky over Ontario farm" - Flickr - Photo Sharing!
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

AmbiPi modified XBMC showing Avatar fire scene + Telldus Control, Raspberry Pi with custom PixelPi
Veröffentlicht am 14.03.2013 Home theathere with modified XBMC running AmbiPi, Raspberry Pi with custom PixelPi showing Avatar fire scene. ...

St Kilda recruit Nathan Freeman to begin pre-season on Monday with modified program
While Jake Carlisle will start the pre-season with St Kilda's youngest players, Nathan Freeman will only be there in part.

Perth gas buses to be modified after fires
Perth's fleet of 474 natural gas-fuelled buses will be taken off the road in stages over the next 18 months so all vehicles can be modified following ...

Modified online children's privacy rules take effect in US - U.S. Federal Trade Commission, regulation ...
Some websites and mobile app developers are confused about how to comply with revised rules governing the online collection of personal information ...

Genetically modified food: The truth about GMO food
IT&#8217;S accused of causing cancer, destroying the environment and storing up devastating health risks for our children. Genetically modified ...

Organic farmer takes genetically modified crop case to WA High Court of Appeal
An organic farmer who failed in a bid to sue his neighbour after genetically modified canola blew onto his West Australian property wants to ...

Mopar showcases modified Jeeps in Dubai
Filed under: Aftermarket , Misc. Auto Shows , Jeep , SUV , Concept Cars , Off-Road The Cherokee KrawLer concept is leading the way for Jeep and ...

Resources last updated: 12/9/2015 11:05:52 AM