c# - Access is denied exception when using Process.Start() to open folder -
i have winforms application in c# have open folder. use
system.diagnostics.process.start(pathtofolder);
this results in following exception:
system.componentmodel.win32exception (0x80004005): access denied
at system.diagnostics.process.startwithshellexecuteex(processstartinfo startinfo)
at system.diagnostics.process.start()
at system.diagnostics.process.start(processstartinfo startinfo)
at myapp.openlogfoldertoolstripmenuitem_click(object sender, eventargs e)
i have checked following things:
- the folder exists
- the user has rights folder (can open in explorer)
another thing if use process.start()
open file inside folder, works.
can give me hint?
cheers
edit goal open folder in explorer. pathtofolder
h:\something\app.name\log
according msdn (https://msdn.microsoft.com/en-us/library/53ezey2s(v=vs.110).aspx) system.diagnostics.process.start(string)
runs file or process (and therefore not open folder). opening folder, https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx sugests might system.diagnostics.process.start(string, string)
first should way explorer, total commander or similar, , second should argument telling used explorer (open folder pathtofolder
).
i suppose system variable stores value "default folder viewer" not know where. try go , return later answer.
hope helps.
edit: did quick digging around , open folder following should trick:
system.diagnostics.process.start(environment.getenvironmentvariable("windir") + @"\explorer.exe", pathtofolder);
where first argument path classical windows explorer , second actual path folder itself. seem widows not hold path other "folder viewer" (such total commander etc.), way off table.
Comments
Post a Comment