如何获取 ClickOnce 数据目录的路径
ApplicationDeployment.DataDirectory 属性
方法一:
string dataDir = (string)AppDomain.CurrentDomain.GetData("DataDirectory");
方法二:
ApplicationDeployment.CurrentDeployment.DataDirectory;
取得路径的位置类似:
C:\Users\用户名\AppData\Local\Apps\2.0\Data\WAHDOYRT.87A\NX24N2BN.WVD\clic..tion_9c409efd14730c52_0001.0000_97346d341e3f8e57\Data
注:红色文字为随机生成的文件夹。
其它获取路径的方法:
String path1 = System.AppDomain.CurrentDomain.BaseDirectory; String path2 = System.IO.Directory.GetCurrentDirectory(); String path3 = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;