Exemplo n.º 1
0
        public static string GetFileHash(string path, bool force = false)
        {
            string _hexStr = null;

            if (_fileHashCache.ContainsKey(path) && !force)
            {
                _hexStr = _fileHashCache[path];
            }
            else if (!File.Exists(path))
            {
                _hexStr = "FileNotExists";
            }
            else
            {
                FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                _hexStr = HashUtil.Get(fs);
                _fileHashCache[path] = _hexStr;
                fs.Close();
            }

            return(_hexStr);
        }