Skip to main content
2 of 4
deleted 29 characters in body
Heslacher
  • 50.4k
  • 5
  • 81
  • 175

finding all png files c#

I have such problem : find all png files to disk and rename them as I did:

static void DirSearch(string sDir)
        {
            try
            {
                var images = Directory.GetFiles(sDir, "*.png");
                images.ToList().AsParallel().WithDegreeOfParallelism(100).ForAll(dd =>
               Rename(dd)
           );


            }
            catch { }

            try
            {
                foreach (string path in Directory.GetDirectories(sDir))
                        DirSearch(path);
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }

        }

Actually a question : whether it is optimized enough ? Need as quickly as possible to process all png files.

Lolidze
  • 201
  • 1
  • 4