Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.27 KB

File metadata and controls

34 lines (28 loc) · 1.27 KB

Total Directory Tree Media Duration(win32)

Do You wanna know your Video Course Total Length ??!!
this Program gives you the total media time of a directory tree

just Publish it with .NETCore and you are Done

piece of code

  TimeSpan DirectoryTreeTotalMediaDuration(string path)
       {
           TimeSpan duration = new TimeSpan(0, 0, 0);
               IEnumerator localDirectories = Directory.EnumerateDirectories(path).GetEnumerator();
               while (localDirectories.MoveNext())
               {
                   duration = duration + DirectoryTreeTotalMediaDuration(localDirectories.Current.ToString());
                   IEnumerator files = Directory.EnumerateFiles(localDirectories.Current.ToString()).GetEnumerator();
                   System.Console.WriteLine(localDirectories.Current.ToString());
                   while (files.MoveNext())
                   {
                       int fileLength = (int)wmp.newMedia(files.Current.ToString()).duration;
                       TimeSpan fileLengthspan = new TimeSpan(0, 0, fileLength);
                       duration = duration + fileLengthspan;
                   }
               }
           return duration;
       }