0

我正在使用 ASP.NET,它也是新手,我正在尝试访问文件服务器上的文件夹,并在不同服务器上的网站内的文件树中查看文件夹中包含的文件。我可以 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 回答