1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public static double GetFileSize(string path) { System.IO.FileInfo fileInfo = null; try { fileInfo = new System.IO.FileInfo(path); } catch (Exception e) { Console.WriteLine($@"获取图片{path}大小失败 Getcatch"); Console.WriteLine(e); return 0; } if (fileInfo != null && fileInfo.Exists) { return System.Math.Ceiling(fileInfo.Length / 1024.0); } else { Console.WriteLine($@"获取图片{path}大小失败 Getelse"); return 0; } }
|