I want to know the way in which I can validate if there is a folder, validate the folder by the name of the folder like Id, and if it exists, open the files it has inside, in this case they are PDF'S, I explain: I have a path of a server where I have several folders stored
and within those folders I have PDF files, in this case there is only one pdf file inside this folder
What I want to do is validate if the folder exists (by the name of the folder), and if it exists, open the files that come within that folder
What I want is to know how to show me the file (s) that come inside the folder, as long as the folder exists by name, do the whole procedure at the press of a button and start the validation and open the records.
Is this what you are looking for?
var dir = new DirectoryInfo(@"C:\Temp");
if (!dir.Exists)
return;
foreach (var file in dir.GetFiles("*.pdf", SearchOption.TopDirectoryOnly))
{
Process.Start(file.FullName);
}
You can wrap it in a method and pass the directory and not hard code it, in real life… also, you would potentially open quite a lot of PDF files like this …
when you do:
var dir = new DirectoryInfo(@"C:\Temp");
if (!dir.Exists)
return;
foreach (var file in dir.GetFiles("*.pdf", SearchOption.AllDirectories))
{
Process.Start(file.FullName);
}
You go through all your sub folders as well