Solved

Explorer Issue

Posted on 2006-10-25
3
163 Views
Last Modified: 2010-04-16
Hi,
I have a forms program that the user clicks on a button and its bring up windows explorer to the following default location here is the current code

            Process x = new Process();
            x.StartInfo.FileName = "C:\\windows\\explorer.exe";
            x.StartInfo.Arguments = "C:\\Program Files\\Application X\\Images";
            try
            {
                x.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error :" + ex.ToString());
            }

How can the code be modified to still open up the to images directory if the program was isntalled to say

"C:\\Program Files\\Application W\\Images";

Thanks

Peter
0
Comment
Question by:schenkp
  • 2
3 Comments
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 17809468
do you mean that Application W does not exists and it still opens Application X ?
well in that case you have to split above string and manualy check if folder exists . or select a "near By" Folder...
           have i understood the question?
0
 
LVL 13

Accepted Solution

by:
joechina earned 500 total points
ID: 17811954
Change
x.StartInfo.Arguments = "C:\\Program Files\\Application X\\Images";
To
x.StartInfo.Arguments = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Substring(6) + "\\Images";


0
 
LVL 13

Expert Comment

by:joechina
ID: 17811960
You can remove the "+\\Images" if your assembly is installed under images directory.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

21 Experts available now in Live!

Get 1:1 Help Now