C # calculate the size of a folder

zhaozj2021-02-16  126

Private void form1_load (Object sender, system.eventargs e) {string a = foldersize (@ "c: //") .tostring (); this.label1.text = a;} public static long folderfilesis (string path) {long Size = 0; try {fileinfo [] files = (New DirectoryInfo (PATH)). getFiles (); foreach (fileInfo file in files) {size = file.length;}} catch (exception ex) {messagebox.show ex.Message);} return size;} public static long FolderSize (string path) {long Fsize = 0; try {Fsize = FolderFileSize (path); DirectoryInfo [] folders = (new DirectoryInfo (path).) GetDirectories (); Foreach (DirectoryInfo Folder In Folders) {fsize = foldersize (folder.fullname);}} catch (exception ex) {messagebox.show;} returnif;}

--forward from

MDOT column

转载请注明原文地址:https://www.9cbs.com/read-13574.html

New Post(0)