filesystems - Dealing with file properties C# -
I want to get the file size of any file using C #, and give it to GB, MB, KB and Bytes if possible ...
And for audio (mp3) files, I need to get the duration of the file ...
You can use to get file size (bytes). Then a simple calculation can tell you KB, MB and GB:
string fileName = "C: \ path \ to \ file.txt"; Var File INFO = New FileInfo (fileName); Console.light line ("length = {0} bytes", fileInfo.Length); Console.light line ("or {0} KB", fileInfo.Length / 1024); Console.light line ("or {0} MB", fileInfo.Length / 1024/1024); Console.lightline ("or {0} GB", file info length / 1024/1024/1024);
In order to obtain the duration of an MP3 file, you will need to use the library (like) which supports the passing of the header of the MP3 file to the reading period.
Comments
Post a Comment