c# - Opening an explorer window with designated file selected -


i have application has option show selected file in folder in file resides. question is, how achieve this?

to clarify, if user in program selected "test.txt" file, want windows explorer window pop , highlight file user selected. can see similar behavior in limewire , utorrent. if select file in either of programs , choose "show in folder", pops windows explorer window file highlighted , selected. trying duplicate behavior.

i tried using following line:

system.diagnostics.process.start("explorer"); 

this popup windows explorer window, however, seems open default in "my documents" folder.

here go,

string filetoselect = @"c:\temp.img"; string args = string.format("/select, \"{0}\"", filetoselect);  processstartinfo pfi = new processstartinfo("explorer.exe", args); system.diagnostics.process.start(pfi); 

note: adding \" before , after {0} parameter enables filetoselect string contain spaces (i.e. "c:\my documents").

from thread:
programmatically select multiple files in windows explorer

cheers,


Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -