2

サーバーAにWebサイトがあり、サーバーBでディレクトリを見つける必要があります。

私のaspxページには、次のものがあります。

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

mbはアセンブリ名のエイリアスです。

私のaspx.csページには、次のものがあります。

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();
}

サーバーが見つからないため、Server.MapPathでエラーがスローされます。ネットワークに接続しています。IISを調べましたが、それは問題ではないと確信しています。もしそうなら、私は本当に詳細が必要になります。どんな助けでもいただければ幸いです。

4

2 に答える 2

0
string ServerPath = System.IO.Path.Combine(
    "//",
    this.fileSystemDataSource.RootPath);

"//"それがあなたが探しているものであると確信していますか?UNCパスは。で始まり"\\"ます。プログラムをデバッグモードで実行してみて、実際のServerPath文字列がどうなるかを確認してください。

于 2012-11-20T22:56:34.170 に答える
0

したがって、DirectoryはServer.MapPathを好みません。UNC文字列をディレクトリコンストラクタにハードコーディングする必要があります。

于 2012-12-11T15:04:32.210 に答える