Open folder with file selected
-
Hi, I use the following code to open a folder1 with window explorer and with file1 inside select. But the problem is that if the desktop has a file with the same filename as file1, it will select the desktop file instead of selecting the right file1 in the folder1 ! Why ? Process p = new Process(); p.StartInfo.Filename = file1; p.StartInfo.WorkingDirectory = folder1Path; p.StartInfo.Arguments = "/Select," + file1; p.Start(); Thanks
-
Hi, I use the following code to open a folder1 with window explorer and with file1 inside select. But the problem is that if the desktop has a file with the same filename as file1, it will select the desktop file instead of selecting the right file1 in the folder1 ! Why ? Process p = new Process(); p.StartInfo.Filename = file1; p.StartInfo.WorkingDirectory = folder1Path; p.StartInfo.Arguments = "/Select," + file1; p.Start(); Thanks
Hi, I think you were quite lucky that your arguments actually started Explorer. Review this http://support.microsoft.com/kb/307856/en-us[^] I would have tried this (not tested):
Process p = new Process();
p.StartInfo.Filename = "explorer.exe"
// p.StartInfo.WorkingDirectory = folder1Path;
p.StartInfo.Arguments = String.Format("\"{0}\" /select,\"{1}\"", folder1Path, file1);
p.Start();where folder1Path and file1 are both fully qualified. Alan.
-
Hi, I use the following code to open a folder1 with window explorer and with file1 inside select. But the problem is that if the desktop has a file with the same filename as file1, it will select the desktop file instead of selecting the right file1 in the folder1 ! Why ? Process p = new Process(); p.StartInfo.Filename = file1; p.StartInfo.WorkingDirectory = folder1Path; p.StartInfo.Arguments = "/Select," + file1; p.Start(); Thanks
I think you can use FindWindowEx to get the SysListView32 of Windows Explorer, then use SendMessage with LVM_SETITEMSTATE to select the items. The difficulty is to know the position of the items. Perhaps LVM_FINDITEM can be used for this. In this way you can also select multiple files.