.NET Framework Bookmark and Share   
 index > .NET Base Class Library > prorgamFilesPath
 

prorgamFilesPath

I'm a bit new to C# So here my problem. I am developing on XP-64bit, there is a 'Program Files' folder and 'Program Files (x86)'. The problem: I had developed this program with a Button on a 32-bit version so it automatically points to 'Program Files' but now that I'm on 64-bit version the program that the Button executes is in 'Program Files (x86)'. Is there any way for the button to search both 'Program Files' folders?
HapRish
You could use environment variables to find the folders. A 32-bit process running in 64-bit Windows has its "Program Files" environment variable point to the C:\Program Files (x86) folder and the "ProgramW6432" variable point to the C:\Program Files folder.
nobugz

Have you tried this?

string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

Best Regards,

Rizwan

RizwanSharp
RizwanSharp wrote:

Have you tried this?

string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

Best Regards,

Rizwan


Oh oops, sorry forgot to mention that I am using that already.

When I click the button to execute the program it errors and tells me that this is faulty.

Program.Start();
HapRish

Hmm, Does every 64 bit machine has both folders side by side? Sorry I have never used 64 bit computer :( but hope to do it in coming months :D.

Hmm I dont know how to distinguish between to paths upon detecting is it running on 64 bit or 32 bit machine but I think you should get fine results using:

SpecialFolder.ProgramFiles on both computersbecause every computer with Windows OS, does have a Program File Folder

Best Regards,

Rizwan

RizwanSharp
You could use environment variables to find the folders. A 32-bit process running in 64-bit Windows has its "Program Files" environment variable point to the C:\Program Files (x86) folder and the "ProgramW6432" variable point to the C:\Program Files folder.
nobugz

You can use google to search for other answers

Custom Search

More Threads

• How do I create a new GUID programatically in VS.Net?
• FileSystemWatcher - event is for a file or folder?
• convert cli::array<unsigned char> into System::String
• How can I specify a daily start time for a windows service?
• XmlNode ReplaceChild();
• How to get value for Terminal Services Home Folder
• FileSystemWatcher
• Passing reference values to C++ functions
• Is it possible to identify the port to which an USB is connected using C#?
• Errors Downloading