简体   繁体   中英

How do I point to the data files for a wpf web application (once published)? Getting the executing directory does not work

So when debugging simply getting the executing path and accessing files in reference to that works fine, eg

string applicationDirectory = System.IO.Directory.GetCurrentDirectory();

or One of the many other ways of getting the directory. It gets the directory with the WPF app in it and I can work with that fine.

However, once I publish the application it no longer works, instead the variable is something like this: Documents and Settings\\ ... \\Apps\\2.0\\MHERCHY1.BJ7\\O0LQQBXT.1GH\\wpfc..xbap_98594a552e5855fe_0001.0000_2df2d386a082f2f3

Which is not where it is installed (but I'm guessing where it is executing from).

So how do I do this? I need a way of pointing to the data resources for the application. Thanks!

USe Assembly.GetEntryAssembly().Location

it will give you the path of your executable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM