0

私も ASP.NET を使用しており、ファイル サーバー上のフォルダーにアクセスして、フォルダーに含まれるファイルを別のサーバー上の Web サイト内のファイル ツリーで表示しようとしています。フォルダに http できますが、ファイル サーバーへの直接パスを使用して接続しようとすると、何も表示されず、エラー ポップも表示されません。私は何を間違っていますか、それとも私が知らない他の問題がありますか? これは機能しているリンクですが、それを使用してファイルサーバーに移動すると何もありません... public const string InterestPenalty = @"D:\Charts\Clayton\Interest Penalty";

私のリンク... public const string InterestPenalty = @"\cfofileserver\Projects\files";

ありがとう!

4

1 に答える 1

0
//get root directory

DirectoryInfo rootDir = new DirectoryInfo(Server.MapPath("~path"));

//create and add the root node to the tree view
TreeNode rootNode = new TreeNode(rootDir.Name, rootDir.FullName);

TreeView1.Nodes.Add(rootNode);

//begin recursively traversing the directory structure
TraverseTree(rootDir, rootNode);


private void TraverseTree(DirectoryInfo currentDir, TreeNode currentNode)

{
    //loop through each sub-directory in the current one
    foreach (DirectoryInfo dir in currentDir.GetDirectories())
    {
        //create node and add to the tree view
        TreeNode node = new TreeNode(dir.Name, dir.FullName);
        currentNode.ChildNodes.Add(node);
        //recursively call same method to go down the next level of the tree
        TraverseTree(dir, node);
    }
    //loop through each sub-directory in the current one
    foreach (FileInfo file in currentDir.GetFiles())
    {
        //create node and add to the tree view
        TreeNode node = new TreeNode(file.Name, file.FullName);
        currentNode.ChildNodes.Add(node);
    }

}
于 2013-04-30T14:13:52.787 に答える