Find all files in a folder

后端 未结 3 1383
别那么骄傲
别那么骄傲 2020-12-01 10:12

I am looking to create a program that finds all files of a certain type on my desktop and places them into specific folders, for example, I would have all files with .txt in

3条回答
  •  悲哀的现实
    2020-12-01 10:59

    You can try with Directory.GetFiles and fix your pattern

     string[] files = Directory.GetFiles(@"c:\", "*.txt");
    
     foreach (string file in files)
     {
        File.Copy(file, "....");
     }
    
     Or Move
    
     foreach (string file in files)
     {
        File.Move(file, "....");
     }     
    

    http://msdn.microsoft.com/en-us/library/wz42302f

提交回复
热议问题