Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Explorer Issue

Posted on 2006-10-25
3
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Expert Comment

by:K V
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 2000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline

610 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