You should split your requirement in two parts:
- getting a list of PDF files in a specific folder
- opening a specific file with default system handler
For the first one, you have to use object in System.IO namespace.
using System.IO;
public static IEnumerable<FileInfo> GetFiles(string path, string extension) {
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists) {
string search = string.Format("*.{0}", extension);
FileInfo[] files = di.GetFiles(search);
foreach (FileInfo fi in files) {
yield return fi;
}
}
}
So, to get all PDF files in "C:\Test" folder, you would write:
IEnumerable<FileInfo> pdfFiles = GetFiles(@"C:\Test", "pdf");
Then you want to open the file(s) obtained; this way:
foreach (FileInfo fi in pdfFiles) {
ProcessStartInfo psi = new ProcessStartInfo(fi.FileName);
psi.UseShellExecute = true;
Process.Start(psi);
}
Hope this helps. Good luck!