网络上的FileInfo.LastWriteTime故障 [英] FileInfo.LastWriteTime Glitch on the network

查看:167
本文介绍了网络上的FileInfo.LastWriteTime故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此图显示了了解问题所需的所有必要数据:
http://img21.imageshack.us/img21/2786/painintheass.png [ ^ ]

我已使用网络驱动器将文件复制到另一个客户端.
比起我将LastWriteTimeUtc设置为定义的值.
当我读取书面文件的LastWriteTimeUtc(我使用Refrech)时,总是会在1-2秒之间出现故障.
首先,我认为它与每个客户的本地时间有关.
我试图同步本地时间或将本地时间设置为gread差异,但没有任何效果.
我还尝试找到二进制精度的一个削减,但不变的数字导致精度为40Sek.而不是1-2秒.是什么告诉我它与精度没有关系.

我还检查了FileInfo的私有数据,它确实不相等:
ftLastWriteTimeLow = 0xabdf4f00
ftLastWriteTimeLow = 0xaaf64ea1

我尽力了.

只是有人想编码(Traget& Source是getter,每次访问都调用.Refresh()):

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;
}

推荐答案

我更改了客户端,问题消失了.

@克里斯蒂安·格劳斯(Christian Graus):
它是快速生成HashValue的一部分,用于检测网络环境中的文件更改.
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.


这篇关于网络上的FileInfo.LastWriteTime故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆