using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System;
using System.Text;

public class Md5 : Editor
{
[MenuItem("Md5/Generate Md5")]
public static void Generate_Md5()
{
//创建一个controller
//AnimatorController mAnimatorController = AnimatorController.CreateAnimatorControllerAtPath("Assets/Resources/Animator/ani.controller");
//EditorUtility.DisplayDialog("Select Texture", "You must select a texture first!", "OK");
string path = EditorUtility.OpenFolderPanel("Choose Directory Path Plz!!!","","");
RecursiveDirectory(path);
}
static void RecursiveDirectory(string path)
{
if (Directory.Exists(path))
{
DirectoryInfo dInfo = new DirectoryInfo(path);
FileInfo[] files = dInfo.GetFiles("*", SearchOption.AllDirectories);
Debug.Log("RecursiveDirectory file length " + files.Length);
for (int i = 0; i < files.Length; ++i)
{
if (files[i].Name.EndsWith(".meta"))
continue;
Debug.Log("RecursiveDirectory Files Name " + files[i].Name + " Md5: "+ GetMd5(files[i].FullName));
}
}
}
static string GetMd5(string path)
{
try
{
FileStream fs = new FileStream(path, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(fs);
fs.Close();
System.Text.StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; ++i)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch (Exception ex)
{
throw new Exception("GetMd5 Exception error: " + ex.Message);
}
}
}

转 这种方法可以免去自己计算大文件md5 的麻烦的更多相关文章

  1. Python:高效计算大文件中的最长行的长度

    在操作某个很多进程都要频繁用到的大文件的时候,应该尽早释放文件资源(f.close()) 前2种方法主要用到了列表解析,性能稍差,而最后一种使用的时候生成器表达式,相比列表解析,更省内存 列表解析和生 ...

  2. day08 学习小测试 九九乘法表 车牌划分计算 大文件读取操作

    1.1需求:读取一个100G的文件,检测文件中是否有关键字keys=['苍老师','小泽老师',"alex"], 如果有则替换成"***",并写入到另一个文件中 ...

  3. C# Large Files MD5 C# 获取大文件MD5

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. bat计算指定文件MD5并输出txt

    @echo off set Name1=*.ADS set Name2=GM_RSSPI* set Name3=equipment* set Name4=protocols* REM 设置输出文件名 ...

  5. Python 大文件处理

    非内存资源可以使用with 在python中逐行读取大文件 在我们日常工作中,难免会有处理日志文件的时候,当文件小的时候,基本不用当心什么,直接用file.read()或readlines()就可以了 ...

  6. php解决大文件断点续传

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

  7. php使用WebUploader做大文件的分块和断点续传

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

  8. B/S架构大文件上传问题

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

  9. JSP大文件分片上传

    核心原理: 该项目核心就是文件分块上传.前后端要高度配合,需要双方约定好一些数据,才能完成大文件分块,我们在项目中要重点解决的以下问题. * 如何分片: * 如何合成一个文件: * 中断了从哪个分片开 ...

随机推荐

  1. 模拟ATM的功能

    import java.io.FileReader; import java.io.FileWriter; import java.io.PrintWriter; import java.util.A ...

  2. mongoose与express

    一.mongoose的使用1.先创建一个项目目录,初始化:npm init -y2.创建一个server.js文件,在该目录下安装mongoose:cnpm install mongoose3.引入m ...

  3. 怎样从外网访问内网Jetty?

    本地安装了一个Jetty,只能在局域网内访问,怎样从外网也能访问到本地的Jetty呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Jetty 默认安装的Jetty端口是8080. 实现步骤 下载并 ...

  4. echarts报错Can't get dom width or height

    echarts图无法显示 一直报错Can't get dom width or height 原因:显示echarts图的div要设置宽高 报错前: <div class="left_ ...

  5. ES6知识整理(10)--class的继承

    (这是es6的第10篇文章.说真的这样的总结之后虽然直观了许多,但是消耗的时间有点长,或许是知识比较复杂的原因吧) 类的继承 有个A类,B类继承A类,那B类实例就可以使用A类实例的所以属性和方法.不包 ...

  6. Solr在Linux中的安装

    在Linux下进行安装: 我已经将压缩包放在了虚拟机下面了,然后开始进行解压缩. tar -zxvf solr-4.10.3.tar 解压完会多一个文件夹.在bin目录下会有这样的一个目录, 其中的这 ...

  7. devexpress 之 ChartControl

    \}5#~mV#cr(/k1yIZ7.Lg

  8. collectd 检测cpu使用率

    环境配置 1. install epel https://www.cyberciti.biz/faq/installing-rhel-epel-repo-on-centos-redhat-7-x/ 2 ...

  9. Codeforces 837E Vasya's Function - 数论

    Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = ...

  10. fatal: unable to access 'https://github.com/open-falcon/falcon-plus.git/': Peer reports incompatible or unsupported protocol version

    git通过git clone下载github上的资源到机器上,结果出现如题所示的错误. [root@server data]# git clone https://github.com/pingcap ...