/// <summary>Gets the size and md5 hash of a file.</summary> public void GetFileSizeAndHash(string relativePath, GetFileSizeAndHashCallback callback) { Debug.Assert(!string.IsNullOrEmpty(relativePath)); Debug.Assert(callback != null); string path = IOUtilities.CombinePath(this.userDir, relativePath); byte[] data = null; Int64 byteCount = -1; string md5Hash = null; if (Steamworks.SteamRemoteStorage.FileExists(path)) { data = Steamworks.SteamRemoteStorage.FileRead(path); if (data != null) { byteCount = data.Length; using (var md5 = System.Security.Cryptography.MD5.Create()) { var hash = md5.ComputeHash(data); md5Hash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); } } } callback.Invoke(relativePath, (data != null), byteCount, md5Hash); }
/// <summary>Gets the size and md5 hash of a file.</summary> public void GetFileSizeAndHash(string relativePath, GetFileSizeAndHashCallback callback) { Debug.Assert(!string.IsNullOrEmpty(relativePath)); Debug.Assert(callback != null); string path = IOUtilities.CombinePath(this.userDir, relativePath); Int64 byteCount; string md5Hash; bool success = this.GetFileSizeAndHash(path, out byteCount, out md5Hash); callback.Invoke(relativePath, success, byteCount, md5Hash); }