Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# DateTime Network
This Picture shows all necessary data to understand the Problem:
http://img21.imageshack.us/img21/2786/painintheass.png[^]
 
I have copy a File to another Client, using a networkdrive.
Than i have set the LastWriteTimeUtc to a defined value.
When i read the LastWriteTimeUtc of the written File (i used Refrech) there is always a glitch betwenn 1-2 Sek.
First i thought its connected with the local Time of each Client.
I tried to sync the local Time or set the local Time to a gread difference without any effect.
I also tried to find a cut in the binary precision but the digit which does not change lead to a precision of 40Sek. and not 1-2Sek. what says me its not connected to a precision.
 
I checked also the private Data of the FileInfo, and it is really not equal:
ftLastWriteTimeLow = 0xabdf4f00
ftLastWriteTimeLow = 0xaaf64ea1
 
I am at my wit's end.
 
Just if someone want to code a little bit (Traget&Source are getter which call .Refresh() on every Access):
 
....
 
Source.LastWriteTimeUtc = DateTime.UtcNow; 
 
Target.LastWriteTimeUtc = Source.LastWriteTimeUtc;
Target.CreationTimeUtc = Source.CreationTimeUtc;
var lLastWriteTimeUtc = ToBinary(Target.LastWriteTimeUtc.Ticks &  0xFFFFFFFF3000000);
var lLastWriteTimeUtc2 = ToBinary(Source.LastWriteTimeUtc.Ticks & 0xFFFFFFFF3000000);
var lLastWriteTimeUtc31 = ToBinary(Target.LastWriteTimeUtc.Ticks & 0xFFFFFFFF0000000);
var lLastWriteTimeUtc32 = ToBinary(Source.LastWriteTimeUtc.Ticks & 0xFFFFFFFF0000000);
var x = new DateTime(Source.LastWriteTimeUtc.Ticks & 0xFFFFFFFF0000000);
var y = new DateTime(Target.LastWriteTimeUtc.Ticks & 0xFFFFFFFF0000000);
 
....
 
//This is just the First hit when i looked for a ToBinary Converter, there is no need for improvement, i dont use it in regular code ;)
public static string ToBinary(Int64 Decimal)
{
    // Declare a few variables we're going to need
    Int64 BinaryHolder;
    char[] BinaryArray;
    string BinaryResult = "";
 
    while (Decimal > 0)
    {
        BinaryHolder = Decimal % 2;
        BinaryResult += BinaryHolder;
        Decimal = Decimal / 2;
    }
 
    // The algoritm gives us the binary number in reverse order (mirrored)
    // We store it in an array so that we can reverse it back to normal
    BinaryArray = BinaryResult.ToCharArray();
    Array.Reverse(BinaryArray);
    BinaryResult = new string(BinaryArray);
 
    return BinaryResult;
}
Posted 13-Nov-12 8:10am
dexit2k437
Comments
Christian Graus at 13-Nov-12 13:13pm
   
Why does it matter ?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I changed the Client and the Problem disappeared.
 
@Christian Graus:
Its a part of a fast HashValue generation, to detect File changes in a Network Environment.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 Jochen Arndt 180
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100