How to pick a file from default location and not by hard coding?


I want to pick my XHTML dtd file from a default location like the bin folder ( where exe file of project resides) and not by hard coding it by giving the exact path of the file like C:\temp\xhtml1.dtd. My code is in C#. Can anyone help how to do it?



One option is to use the application-base:

string path = Path.Combine(
            AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
            "foo.dtd");

I think this might be what you want?

string xhtml = Directory.GetCurrentDirectory()+"xhtml1.dtd";