Solved

Program Files x86 Path

Posted on 2011-09-27
10
854 Views
Last Modified: 2012-05-12
Hi,
How can I get path to Program Files (x86) ?
0
Comment
Question by:mastiSoft
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 4

Expert Comment

by:jschristian44
Comment Utility
I am unsure of what you mean.  Please clarifiy a little better?  The Program Files (x86) is where Windows stores files that are specific for 32-bit software.  All of the programs you install go into there.  It is in My Computer>C:>Program Files (x86).  If you want a shortcut to there to add to your desktop, just right click on the Program Files folder and click create shortcut.  Then drag it to your desktop.
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)
0
 
LVL 1

Author Comment

by:mastiSoft
Comment Utility
Hi
I need to get path to application that have exe file in Program Files(x86). Yes the PC is 64-bit bit.
I used the last suggestion and see what happens:
Error103      'ProgramFilesX86' is not a member of 'System.Environment.SpecialFolder'.
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
You will have to move to a newer version of Visual Studio. Older versions were designed before Microsoft started to use the x86 Program Files and do not have a definition for that special folder.

What version do you use?

I am puzzled by you Error 103. .NET does not use error codes. Could you sent a PrintScreen?
0
 
LVL 11

Expert Comment

by:cup
Comment Utility
It is in the environment variable %programfiles(x86)%.  If you get the environment variable, expand it and use it as part of the file path, then you don't need to mess with the SpecialFolders.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:mastiSoft
Comment Utility
to JamesBurger:
I use VS 2010. But I use to use Framework 2 because I don't want  tell to  my users to  install Framework 4 only to rum my application.
to Cup:
"It is in the environment variable %programfiles(x86)%." can you give me some example?
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
Strange idea not to ask users to install Framework 4. Unless you work with a very restrictive system manager that would still run Windows 3.1 because he fears that anything newer is not stable or secure enough, there is no reason to have your users make the move if you are developing in a tool that has been geared for that version.

Its like continuing to develop for VB4 because you do not want your users to install the VB6 runtime. You will tell me that the runtimes were a lot smaller in those times, but 2 GB hard disks where also smaller than what we get to day.

The framework installs in a snap. Framework 4 commes with framework 2 built-in, with extras, bugs that have been solved since 2007 (the last SP for framework 2.0), and enhanced performance on the top of that.

They have a 64-bits computer and run on a technology that is 8 years old? Why have such a computer if you use something that cannot access all its power? When you want to access specific features of their computer, you cannot do it because framework 2.0 is not designed for those features.

Don't get me wrong. I do not have a cell phone. I won't move to Denari (SQL Server 2012?) until I am forced to. I am not the kind of guy to jump on every new technology. But the framework 4.0 is old enough to have proven that it is stable and it has been designed for the types of computers you users have.

Restraining yourself and your users to the 2.0 framework is like continuing to use leaded gas in your car or listening to music on tape cassettes that cannot play at the right speed anymore, when the MP3 player (Framework 4.0) is free for the taking.

Unless they are in a very controlled environment, the first or second little thing they will grab for free on the Internet will require Framework 4.0 anyway. They might already have it unknowingly.
0
 
LVL 11

Accepted Solution

by:
cup earned 500 total points
Comment Utility
Something like this
Imports System.Environment
Module EnvVar

    Sub Main()
        Dim progfiles As String
        progfiles = Environment.GetEnvironmentVariable("programfiles(x86)")
        Console.WriteLine("It is " & progfiles)
    End Sub

End Module

Open in new window

0
 
LVL 11

Expert Comment

by:cup
Comment Utility
I can empathize with mathiSoft.  I work in some environments which don't even have .net framework installed.  Sometimes the choice is down to whether you install .net framework for that one program or write it in something like VB6 or C++ that doesn't require .net framework.
0
 
LVL 1

Author Comment

by:mastiSoft
Comment Utility
Hi Jamesburger,
You don't do much programming for the US military, do you? No, I didn't think so.
Thanks for your extensive and useless lesson.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now