【Unity开发】获取文件的MD5
2016-01-07 14:10
393 查看
文件的MD5值是独一无二的,所以当MD5值改变时说明文件改变了
近期做移动端的断点续传正是运用到这一特性。
近期做移动端的断点续传正是运用到这一特性。
using UnityEngine; using System.Collections; using System.Net.NetworkInformation; using System.IO; using System; using System.Text; public class Test : MonoBehaviour { // Use this for initialization void Start() { try { //指定文集为根目录下的Test.cs FileStream fs = new FileStream(Application.dataPath + "/Test.cs", FileMode.Open); System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] retVal = md5.ComputeHash(fs); fs.Close(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < retVal.Length; i++) { sb.Append(retVal[i].ToString("x2")); } print(sb); } catch (Exception ex) { throw new Exception("md5file() fail, error:" + ex.Message); } } }
相关文章推荐
- 【Unity】unity打包下载(参考)
- 【Unity3D游戏开发】UnityEditor.UI.dll timestamps but is not known in guidmapper...
- Unity3D Editor 扩展
- Unity 数据存储
- unity中解析excel导出的txt文件
- Unity 存储目录
- 在unity通过组件名称(string)添加脚本
- 简单的Animation实现角色行走(学习笔记)
- Unity3d在安卓android的更新(APK覆盖)
- Unity中一键创建常用文件夹
- Unity中一键创建常用文件夹
- unity终极抗锯齿抗白边黑边投影阴影不正常问题解决
- Unity 高版本项目 移植到 低版本
- Unity项目开发准则
- Unity CCTween UGUI 动画插件
- Unity中消息事件的封装与运用
- Unity中的Path对应各平台中的Path
- Unity_Shader开发_Shaderlab(三)---------2016.1.6
- Unity3D 的物理渲染和光照模型
- 游戏动作师使用Unity3D遇到过的所有问题