c# - How to get relative path of file which is in project folder? -


i tried using @"~\testdata\test.xml", trying file bin/debug instead of project folder.

you can achieve getting parent of current directory, using directory class in system.io namespace. see code example.

using system.io;  namespace consoleapplication15 {     class program     {         static void main(string[] args)         {             var projectfolder = directory.getparent(directory.getcurrentdirectory()).parent.fullname;             var file = path.combine(projectfolder, @"testdata\test.xml");         }     } } 

Comments

Popular posts from this blog

javascript - How do you prevent nested queries/catches in sequelize? -

java - Could not retrieve pre-bound Hibernate session - Could not obtain transaction-synchronized Session for current thread -

ruby on rails - ActiveRecord order not working -