Skip to content

Commit

Permalink
Update functions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tidy-Coder authored Aug 6, 2024
1 parent b00f614 commit e7ab257
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions c#/functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,27 @@ bool clear(string tidyPath){
}
return false;
}
long sizeDirectory(DirectoryInfo tidyInfoHere){
long tidyNumReturn = 0;

foreach(FileInfo f in tidyInfoHere.GetFiles()){
tidyNumReturn += f.Length;
}
foreach(DirectoryInfo infoIsHere in tidyInfoHere.GetDirectories()){
tidyNumReturn += this.sizeDirectory(infoIsHere)
}
return tidyNumReturn
}
long size(string tidyPath){
if(this.isFile(tidyPath)){
return (new FileInfo(tidyPath)).Length;
}
else if(this.isFolder(tidyPath)){
return this.sizeDirectory(new DirectoryInfo(tidyPath));
}
else{
return -1;
}
}
}
}

0 comments on commit e7ab257

Please sign in to comment.