I think this will direct you in the right direction. Since this is like deploying through ClickOnce, you should get the necessary information here:
System.Deployment.Application.ApplicationDeployment.CurrentDeployment
this class can be found in System.Deployment.dll
Unfortunately, the CurrentDeployment object does not actually tell you where the application works, so you need to do one more job CurrentDeployment
if you call this:
var datadir = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory
you will get something like this (for data directory)
C: \ Users \ Administrator \ AppData \ Local \ Apps \ 2.0 \ Data \ BVPTZA5G.3AC \ WC2WBZ92.D96 \ expe..tion_ba14dd6bedbd6876_0000.0009_7919ca38a4e51341 \ Data \ 1.0.0.0
from there you need to get the folder name of the bold folder above, because the application works here (and not the data directory):
C: \ Users \ Administrator \ AppData \ Local \ Apps \ 2.0 \ RCVHD71Y.7CQ \ BC42YMHT.ZQ0 \ expe..tion_ba14dd6bedbd6876_0000.0009_7919ca38a4e51341
So, I would create a function that
- Accepts the first file path
- Defines a randomly generated folder name
- finds an application folder based on the name of this folder (which contains your executable files)
I think that creating an extension method of type ApplicationDeployment would be appropriate.
Hope that helps
Jose source share