czwartek, 23 stycznia 2014

How to get ProgramFiles path?


Environment.SpecialFolder.ProgramFiles should return the Program Files (x86) folder for a 32-bit application and Program Files for a 64-bit application on 64-bit Windows.
Check your project configuration settings.

The result depends on what platform is your project targeting. If you target x86, then both Environment.SpecialFolder.ProgramFiles and Environment.SpecialFolder.ProgramFilesX86 will return the same path.



RETURN APPLICATION SPECIFY PROGRAM FILE PATH


//RETURN:  ' C:\\Program Files' for 64    or   'C:\\Program Files (x86)'  for 86
String folderPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);


------------------------------------------------------------------------------------------------------------------------------

RETURN DEFINED IN VARIABLE PROGRAM FILE PATH (in 64bit application)

// RETURN: C:\Program Files (x86)
String x86folder = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
 
// RETURN: C:\Program Files
String x64folder = Environment.GetEnvironmentVariable("ProgramFiles");

------------------------------------------------------------------------------------------------------------------------------

http://msdn.microsoft.com/en-us/library/System.Environment%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx

http://stackoverflow.com/questions/194157/c-sharp-how-to-get-program-files-x86-on-windows-vista-64-bit
http://stackoverflow.com/questions/12710958/how-to-get-programfiles-paths

http://msdn.microsoft.com/en-us/library/system.environmentvariabletarget%28v=vs.110%29.aspx
http://www.dreamincode.net/forums/topic/178713-working-with-environment-variables-in-c%23/

http://www.greengingerwine.com/index.php/2011/05/output-paths-environment-variables-in-csharp/

Brak komentarzy:

Prześlij komentarz