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. Dir Search On Server

Dir Search On Server

Scheduled Pinned Locked Moved C#
sysadmintutorialquestion
5 Posts 2 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.
  • I Offline
    I Offline
    IrishSonic
    wrote on last edited by
    #1

    Hiya Does anyone know how to search for all directories on the C:\\ for a server?? I have a web server on a remote machine and need to list certain directories on that machine. I do have full permissions to the machine. Have tried this: foreach (string d in Directory.GetDirectories("\\ip address\\C:\\")) { MessageBox.Show( d.ToString() ); } Thanks.

    H 1 Reply Last reply
    0
    • I IrishSonic

      Hiya Does anyone know how to search for all directories on the C:\\ for a server?? I have a web server on a remote machine and need to list certain directories on that machine. I do have full permissions to the machine. Have tried this: foreach (string d in Directory.GetDirectories("\\ip address\\C:\\")) { MessageBox.Show( d.ToString() ); } Thanks.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).

      Microsoft MVP, Visual C# My Articles

      I 2 Replies Last reply
      0
      • H Heath Stewart

        You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).

        Microsoft MVP, Visual C# My Articles

        I Offline
        I Offline
        IrishSonic
        wrote on last edited by
        #3

        Thanks for that. Only need to search for Directories not files. Will look into it.

        1 Reply Last reply
        0
        • H Heath Stewart

          You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).

          Microsoft MVP, Visual C# My Articles

          I Offline
          I Offline
          IrishSonic
          wrote on last edited by
          #4

          Could you actually show me how to use this while I am considering other options. Have tried: foreach (string sDir in Directory.GetDirectories("ip\\C$:\\")) { MessageBox.Show( sDir.ToString() ); }

          H 1 Reply Last reply
          0
          • I IrishSonic

            Could you actually show me how to use this while I am considering other options. Have tried: foreach (string sDir in Directory.GetDirectories("ip\\C$:\\")) { MessageBox.Show( sDir.ToString() ); }

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            I did: \\SERVER\C$. You could also use \\IP\C$. Don't use a colon (:). That's the admin share for a drive, which Windows NT establishes for each local drive automatically. And you don't need to call sDir.ToString because it's already a string.

            foreach (string dir in Directory.GetDirectories("\\SERVER\C$"))
            Console.WriteLine(dir);

            Microsoft MVP, Visual C# My Articles

            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