Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Open folder with file selected

Open folder with file selected

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kim0618
    wrote on last edited by
    #1

    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

    A C 2 Replies Last reply
    0
    • K Kim0618

      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

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • K Kim0618

        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

        C Offline
        C Offline
        carlecomm
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups