简体   繁体   English

如何从C#检索/获取CAB FileUnique版本号?

[英]How to Retrieve / Get CAB FileUnique Version Number From C#?

I have an application in windows mobile 6.after deploying the application,it will create a CAB file. 我在Windows Mobile 6中有一个应用程序。部署该应用程序后,它将创建一个CAB文件。 I Want to Upload this CAB file To Server using File Upload Control From Asp.Net Web Form.. 我想使用Asp.Net Web窗体中的文件上载控件将此CAB文件上载到服务器。

While Uploading I want to check the CAB file is already Uploaded Before by checking its version number[Unique Generated by .NET while Deploying] rather than Just its name. 在上载时,我要检查CAB文件是否已上载,方法是检查其版本号[部署时由.NET唯一生成],而不是检查其名称。

How to get this unique version from C# ??? 如何从C#获得此唯一版本?

Please help me on this..... 请帮我这个.....

Thanks in Advance 提前致谢

Why not just use an MD5 hash of the file itself? 为什么不只使用文件本身的MD5哈希呢? That's going to give you a pretty good uniqueness. 这将为您提供非常好的独特性。

public string GetFileHash(string fileName)
{
    using (var stream = File.Open(fileName, FileMode.Open))
    {
        var md5 = new MD5CryptoServiceProvider();
        var hash = md5.ComputeHash(stream);

        var sb = new StringBuilder();
        for (int i = 0; i < hash.Length; i++)
        {
            sb.Append(hash[i].ToString("x2"));
        }
        return sb.ToString();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM