0

私はツリービューが初めてです。ツリービューでローカル ディレクトリのログ ファイルを表示し、それをクリックすると、ファイルが開くはずです。以下は私のコードです:

1) 私の aspx ページ:

<asp:TreeView ID="tvLogResults" runat="server" ExpandDepth="1" OnSelectedNodeChanged="tvLogResults_SelectedNodeChanged" style="margin-left: 33px; margin-top: 16px;">
                        <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
                        <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="0px"
                            NodeSpacing="0px" VerticalPadding="0px" />
                            <ParentNodeStyle Font-Bold="False" />
                            <RootNodeStyle ImageUrl="~/Styles/imgs/open-folder.jpg" />
                            <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
                        </asp:TreeView>

2) コードビハインド

protected void btnSearch_Click(object sender, EventArgs e)
    {
        TreeNode n = new TreeNode();
        n.Value = "0";
        n.Text = "LogFiles-Datewise";
        n.SelectAction = TreeNodeSelectAction.Select;
        tvLogResults.Nodes.Add(n);


        string data = txtFromDate.Text;
        DateTime fromDate = DateTime.ParseExact(data, "MM/dd/yyyy", null);

        DateTime toDate = DateTime.Parse(txtToDate.Text);

        string path = string.Concat(HttpRuntime.AppDomainAppPath, @"LogFiles");



        var files = from c in currDirectory.GetFiles()
                    where c.CreationTime >= fromDate && c.CreationTime <= toDate
                    select c;
        int i = 1;
        foreach (FileInfo file in files)
        {
            DateTime lastAccessTime = file.LastAccessTime;
            TreeNode child = new TreeNode();
            child.Value = file.FullName;
            child.Text = lastAccessTime.ToString("MM/dd/yyyy");
            child.PopulateOnDemand = true;
            child.NavigateUrl = file.FullName;
            child.SelectAction = TreeNodeSelectAction.Select;
            tvLogResults.Nodes[0].ChildNodes.Add(child);
            i++;
        }
    }

    protected void tvLogResults_SelectedNodeChanged(object sender, EventArgs e)
    {
        string filename = Server.MapPath(tvLogResults.SelectedValue);

        System.IO.FileInfo file = new System.IO.FileInfo(filename);

        if (file.Exists)
        {
            System.Diagnostics.Process.Start(file.FullName);
        }
    }

ノードを選択している間、フルパスが「file:\\C:\TraceFiles\Log11Nov.txt」(IE & Chrome) として表示されますが、ファイルは開きません。ノードをクリックしても何も起こりません。助けてください。

4

1 に答える 1