Connecting Tech Pros Worldwide Help | Site Map

Showing document in Windows Explorer

  #1  
Old July 1st, 2009, 06:07 PM
Member
 
Join Date: Feb 2009
Posts: 35
I'm programming a download manager and I'm trying to implement the "Show Containing Folder" feature that you would find in Firefox.

This is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. Process proc = new Process();
  2. proc.StartInfo.FileName = "explorer.exe";
  3. proc.StartInfo.Arguments = dlPath;
  4. proc.Start();
This simply opens the folder but in Firefox, it hilights the file. How would I do that?
  #2  
Old July 1st, 2009, 07:26 PM
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,569

re: Showing document in Windows Explorer


Here's what I would do:
Expand|Select|Wrap|Line Numbers
  1. //change this line to whatever path you have:
  2. string filepath = @"c:\dev\pointredemption.txt";
  3. FileInfo fi = new FileInfo(filepath);
  4. if (fi.Exists)
  5. {
  6.     Process proc = new Process();
  7.     proc.StartInfo.FileName = "explorer.exe";
  8.     proc.StartInfo.Arguments = "/select," + filepath; ;
  9.     proc.Start();
  10. }
  11. else
  12.     Console.WriteLine("DNE!");
Make sure to include using System.IO; to use the FileInfo object.

Basically, this will check to see if the file exists. If it does, it will start explorer and highlight the file. Otherwise, it will write to the console, but you can change that part.

Hope this helps.

Source: http://support.microsoft.com/kb/314853
  #3  
Old July 1st, 2009, 11:06 PM
Member
 
Join Date: Feb 2009
Posts: 35

re: Showing document in Windows Explorer


Perfect. Thank you!

20 characters....
Reply

Tags
folder, show


Similar Threads
Thread Thread Starter Forum Replies Last Post
finding user's My Documents Michael Mayer answers 8 November 15th, 2005 02:29 PM
FAQ update (roundup of pending requests - for comment) Richard Cornford answers 42 July 20th, 2005 02:38 PM