Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

how to find a specific file in a Folder.

in WinForm Application
Posted

Use the static methods in the type System.IO.Directory.
The method's name is GetFiles(...) and comes with three different signatures:

Excerpt from MSDN:
SQL
String[] GetFiles(String)                        //Returns the names of files (including their paths) in the specified directory.
String[] GetFiles(String, String)                //Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
String[] GetFiles(String, String, SearchOption)  //Returns the names of files (including their paths) that match the specified
                                                   search pattern in the specified directory, using a value to determine whether to search subdirectories.


Regards,

— Manfred
 
Share this answer
 
v2
XML
Using this C# code, a window application can access/find all or a specific file (if mentioned) in a Folder.on load
use

<pre lang="cs">private void Form1_Load(object sender, EventArgs e) {
            string[] array1 = Directory.GetFiles(@"C:\MyTemplates", "*.docx");
            foreach (string name in array1) {
                comboBox1.Text = name;
                comboBox1.Items.Add(Path.GetFileName(name));
            }
        }&lt;/pre&gt;</pre>
 
Share this answer
 
Comments
Mulla Rameez 4-Jul-13 8:56am    
Use System.IO.Directory.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900