FSO.Common.Utils.FileUtils.ComputeMD5 C# (CSharp) Method

ComputeMD5() public static method

public static ComputeMD5 ( string filePath ) : string
filePath string
return string
        public static string ComputeMD5(string filePath)
        {
            var bytes = ComputeMD5Bytes(filePath);
            return BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant();
        }

Usage Example

Ejemplo n.º 1
0
        private string ExportSpriteFrame(SPR2Frame frame)
        {
            var texture = frame.GetTexture(this.Gd);

            var temp = Path.GetTempFileName();

            texture.SaveAsPng(new FileStream(temp, FileMode.OpenOrCreate), texture.Width, texture.Height);

            var hash     = FileUtils.ComputeMD5(temp);
            var filename = id + "_files/" + hash + ".png";
            var newDest  = Path.Combine(dir, filename);

            if (File.Exists(newDest))
            {
                File.Delete(temp);
            }
            else
            {
                File.Move(temp, newDest);
            }

            return(filename);
        }