Note that there are some explanatory texts on larger screens.

plurals
  1. POFind file in program files and launch that file
    text
    copied!<p>I'm attempting to write a program that downloads Team Viewer and installs it and if its already installed, launch teamviewer from programfiles instead of re-downloading it.</p> <p>I have it so it downloads and installs teamviewer into the correct folder but i cant figure out how to tell my program to search in either Program Files (x86) for 64bit or program files for 32 bit search the directory and sub directories for teamviewer.exe and launch the program. Here is the code i have so far.</p> <p>Thanks.</p> <p>I solved it using this code. It searches for Teamviewer in the correct program files folder and launches the program . This does not check if you have it installed or not, i have a check earlier in my program that detects it but it would be easy to add.</p> <pre><code>private void teamviewerbtn_Click(object sender, EventArgs e) { //start button if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE").Contains("64")) { string path = @"c:\Program Files (x86)\Teamviewer\"; //specify starting folder location for searching string searchPattern = "teamviewer.exe*"; //what do you want to search for? DirectoryInfo di = new DirectoryInfo(path); FileInfo[] files = di.GetFiles(searchPattern, SearchOption.AllDirectories); foreach (FileInfo file in files) { string tvE = (file.FullName.ToString()); //takes found file and references full file path Process.Start(tvE); } } else { string path = @"c:\Program Files\Teamviewer\"; //specify starting folder location for searching string searchPattern = "teamviewer.exe*"; //what do you want to search for? DirectoryInfo di = new DirectoryInfo(path); FileInfo[] files = di.GetFiles(searchPattern, SearchOption.AllDirectories); foreach (FileInfo file in files) { string tvE = (file.FullName.ToString()); //takes found file and references full file path Process.Start(tvE); } } //end button } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload