using System.IO;
Tip: you can also check if a file exists, and optionally create it.
string folder = "C:\\Projects\\Notes"; // escaped path
// Or, the easier way:
string folder = @"C:\Projects\Notes"; // string literal
string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MyFolder";
if( Directory.Exists( folder ) )
// Folder exists - write useful code here...
else
MessageBox.Show("This folder doesn't exist!");
Note: you can of course directly pass the path as argument; we didn't here to keep things simple.
int numberOfTextFiles = Directory.GetFiles( folder, "*.txt" ).Length;