Find files on a remote server

Posted by Peter Kelly on Stack Overflow See other posts from Stack Overflow or by Peter Kelly
Published on 2010-05-06T13:27:30Z Indexed on 2010/05/07 14:38 UTC
Read the original article Hit count: 226

Filed under:
|

I have a web-service that resides on serverA. The webservice will be responsible for finding files of a certain type in a virtual directory on serverB and then returning the full URL to the files.

I have the service working if the files are located on the same machine - this is straight-forward enough. My question is what is the best way to find all files of a certain type (say *.xml) in all directories below a known virtual directory on a remote server?

So for example, the webservice is on http://ServerA/service.asmx and the virtual directory is located at http://serverB/virtualdirectory

So in this code, obviously the DirectoryInfo will not take a path to the remote server - how do I access this so I can find the files it contains? How do I then get the full URL to a file found on that remote server?

        DirectoryInfo updateDirectory = new DirectoryInfo(path);

        FileInfo[] files = 
             updateDirectory.GetFiles("*.xml", SearchOption.AllDirectories);

        foreach (FileInfo fileInfo in files)
        {
            // Get URL to the file
        }

I cannot have the files and the service on the same server - IT decision that is out of my hands.

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about web-services