开发者

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

开发者 https://www.devze.com 2023-01-13 22:51 出处:网络
So when debugging simply getting the executing path and accessing files in reference to that works fine, e.g.

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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号