How to get a ClickOnce application path and version number using C#/.NET code? -
i want path , version number of clickonce application, provided name of clickonce application.
when manually searched it, found @ path follows:
'c:\users\krishnaim\appdata\local\apps\2.0\1hcg3kl0.k41\vo5bm4jr.rpo\head..tion_7446cb71d1187222_0005.0037_37dfcf0728461a82\headcount.exe' but keeps on changing, , become hard-coded path. there way clickonce application (for example, headcount.exe installed) path , version number using c#/.net code?
it seems little bizarre, getting current directory of executing assembly bit tricky code below may doing more think should, assure mitigating issues others may attempt use assembly.getexecutingassembly.location property.
static public string assemblydirectory { { //don't use assembly.getexecutingassembly().location, instead use codebase property string codebase = assembly.getexecutingassembly().codebase; uribuilder uri = new uribuilder(codebase); string path = uri.unescapedatastring(uri.path); return system.io.path.getdirectoryname(path); } } static public string assemblyversion { { var asm = assembly.getexecutingassembly(); //if want full four-part version number: return asm.getname().version.tostring(4); //you can reference asm.getname().version major, minor, majorrevision, minorrevision //components individually , them please. } }
Comments
Post a Comment