Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a string of the form %programfiles%\directory\tool.exe to a useable Filename in C#/.net?

Tags:

c#

.net

file

I have an application which takes a string value of the form %programfiles%\directory\tool.exe from its application config file.

I want to make this into a useable filename so that I can call

System.Diagnostics.Process.Start(filename)

and have it execute the application. I'm curently getting a System.ComponentModel.Win32Exception - The system cannot find the file specified

Many thanks for any help with this.

like image 739
Sam Meldrum Avatar asked Oct 23 '08 09:10

Sam Meldrum


1 Answers

filename = Environment.ExpandEnvironmentVariables(filename);
like image 173
Marc Gravell Avatar answered Sep 27 '22 20:09

Marc Gravell