拷贝与剪切的性能
class Program { static void Main(string[] args) { CopyToTest(); MoveToTest(); Console.ReadLine(); } static string[] GetImgFiles() { string path = @""; return Directory.GetFiles(path, "*.jpg", SearchOption.AllDirectories); } static string[] GetImgFiles1() { string path = @"D:\TIANDITU\DATA\POIDATA\大众点评网\川菜\bjc"; return Directory.GetFiles(path, "*.jpg", SearchOption.AllDirectories); } static void MoveToTest() { string root = @""; DateTime dtStart = DateTime.Now; string[] arr = GetImgFiles1(); int counter = 0; foreach (string item in arr) { string target = Path.Combine(root, counter.ToString() + ".jpg"); File.Move(item, target); counter++; } DateTime dtEnd = DateTime.Now; TimeSpan ts = dtEnd - dtStart; Console.WriteLine("statistics for move"); Console.WriteLine(ts.TotalSeconds); Console.WriteLine(ts.TotalMinutes); } static void CopyToTest() { string root=@"D:\TIANDITU\DATA\POIDATA\大众点评网\川菜\bjc"; DateTime dtStart = DateTime.Now; string[] arr = GetImgFiles(); int counter = 0; foreach (string item in arr) { string target = Path.Combine(root, counter.ToString()+".jpg"); File.Copy(item, target); counter++; } DateTime dtEnd = DateTime.Now; TimeSpan ts = dtEnd - dtStart; Console.WriteLine("statistics for copy"); Console.WriteLine(ts.TotalSeconds); Console.WriteLine(ts.TotalMinutes); } }