I want to read a .config file. Before I read the file I need to make sure whether the file is in the folder or not.
At the moment i am using a System.Configuration.AppSettingsReader to read the configuration file it only reads when the file is in the folder as soon as i moved the file in different folder i throws me a error. But i don’t know how to check whether there is a .config file in a folder or not.
What i want to do is if the .config is in the folder get reader.getvalue and perform some action and if the .config file is not in the folder do something else.
Is ther any way of checking just the extension of the particular file in C# ?
thanks
Just use simple
System.IO.File.Exists(path)method to check the file exists in the c. Here is MSDN article