Find directory on different server C#

Posted by rainhider on Stack Overflow See other posts from Stack Overflow or by rainhider
Published on 2012-11-20T20:42:52Z Indexed on 2012/11/20 23:01 UTC
Read the original article Hit count: 250

Filed under:
|
|

I have a website on Server A and it needs to find a directory on Server B.

On my aspx page, I have:

<mb:FileSystemDataSource
    ID="fileSystemDataSource" runat="server"
    RootPath="\\servername\Folder\Subfolder"
    FoldersOnly="true" />

mb is assembly name alias.

On my aspx.cs page, I have:

protected void Page_Load(object sender, EventArgs e)
{
    DataTable gridviewSource = DisplayFilesInGridView();
    DataRow gridviewRow;

    //sets the server path so it does not default to current server
    string ServerPath = System.IO.Path.Combine(
        "//",
        this.fileSystemDataSource.RootPath);

    //Get All Folders Or Directories and add in table
    DirectoryInfo directory = new DirectoryInfo(Server.MapPath(ServerPath));
    DirectoryInfo[] subDirectories = directory.GetDirectories();
}

Well, it throws an error on the Server.MapPath because it cannot find the server. I am connected to the network. I looked at IIS, and I am pretty sure that is not the problem. If so, I would really need specifics. Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET