select a file in Explorer

  • Thread starter Sergey Poberezovskiy
  • Start date
S

Sergey Poberezovskiy

Hi,

As part of my Windows application, I need to open a folder
containing a file (fileName is specified in txtFile).
I have no problem opening the folder:
FileInfo info = new FileInfo(txtFile.Text);
string folderName = info.DirectoryName;
System.Diagnostics.ProcessStartInfo prStartInfo = new
System.Diagnostics.ProcessStartInfo;
prStartInfo.FileName = "explorer";
prStartInfo.UseShellExecute = true;
prStartInfo.WindowStyle = ProcessWindowStyle.Normal;
prStartInfo.Arguments = '"' + folderName + '"';
System.Diagnostics.Process.Start(prStartInfo);

But how do I select the file within the opened directory?

Any help is much appreciated.
 
S

Sergey Poberezovskiy

Cor,

I know how to use OpeFileDialog, and that was not the
question. If you take a look at the code supplied, it
opens a new explorer window in a separate process. The
functionality I am trying to achieve is something similar
to what happens when you click on FindTarget button in
File Properties explorer dialog box, when a folder
containing the file is opened and the file is selected.
It has nothing to do with opening a standard dialog.

P.S. the reason that I created a separate post in VB is
that the code there is in VB (and not C#) which makes it
easier for VB community to read (at least it made for me
when I only did VB).

Hope you can still help me with my problem (in either
language).

Kind regards,

Sergey
 
C

Cor Ligthert

Sergey,

My question was as well stated to get more information in this thread.

I have no answer and I go out so have no time to eveluate it for you
directly, however maybe others know.

However find target is of course directly linked to a file that is in that
box. In my opinion not to explorer. Why do you than not build yourself an
own box.

I have not used them yet, however did you see these controls there are some
special file controls in it.

Download
http://www.gotdotnet.com/Community/Workspaces/workspace.aspx?id=167542e0-e435-4585-ae4f-c111fe60ed58

Description
http://msdn.microsoft.com/vbasic/de...chart/html/vbpowerpack.asp#vbpowerpack_topic8

I think it will not help however you never know?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top