Solved

Explorer Issue

Posted on 2006-10-25
3
165 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlDependency to get update from sql to my c# app 2 64
Printing 1 58
What Does This C# Code Block Do? 5 56
RegEx with optional part 4 42
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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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