Exemplo n.º 1
0
        /// <summary>
        /// Generates a new instance of HashInfo which stores information about the hash
        /// </summary>
        /// <param name="filename">The name of the file that has been hashed</param>
        /// <param name="hash">The file's hash</param>
        /// <returns>Returns a new instance of HashInfo containing information avout the specified file. On error returns null</returns>
        private HashInfo getHashInfo(string filename, string hash)
        {
            //check if file exists and hash is valid
            if (!File.Exists(filename) || hash.IsNullOrEmpty())
                return null;

            //Initialize new instance of HashInfo
            var result = new HashInfo() { FileName = filename, Hash = hash };

            //Load information about the file from disk and set HashInfo properties
            var info = new FileInfo(filename);

            result.Created = info.CreationTimeUtc;
            result.LastEdited = info.LastWriteTimeUtc;
            result.Size = info.Length;

            return result;
        }