Click here to Skip to main content
15,886,061 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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):

C#
....

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
Comments
Christian Graus 13-Nov-12 13:13pm    
Why does it matter ?

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900