I am using:
File.Exists(filepath)
What I would like to do is swop this out for a pattern, because the first part of the filename changes.
For example: the file could be
01_peach.xml 02_peach.xml 03_peach.xml
How can I check if the file exists based on some kind of search pattern?
You can do a directory list with a pattern to check for files
string[] files = System.IO.Directory.GetFiles(path, "*_peach.xml", System.IO.SearchOption.TopDirectoryOnly); if (files.Length > 0) { //file exist }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With