“System.IO.FileInfo”不包含“FileName”的定义;

发布于 2024-10-31 16:38:43 字数 2290 浏览 0 评论 0原文

<asp:GridView runat="server" id="GrdVw_Download">
                        <RowStyle cssclass="ItemStyle" />
                        <HeaderStyle cssclass="tableheader" horizontalalign="Left" />
                        <AlternatingRowStyle cssclass="AlternateItemStyle" horizontalalign="Left" />
                        <FooterStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
                        <Columns>
                            <asp:BoundField headertext="File name" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="FileName" />
                            <asp:BoundField headertext="File Size" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                dataformatstring="{0:#,### bytes}" datafield="Length" />
                            <asp:BoundField headertext="Extension" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="Extension" />
                            <asp:TemplateField headertext="Download Brochure" itemstyle-horizontalalign="Center"
                                headerstyle-horizontalalign="Center">
                                <ItemTemplate>
                                    <a href="?dl=<%# Encryptor.encrypt(((FileInfo)Container.DataItem).FullName) %>" 
                                    title="Download <%# ((FileInfo)Container.DataItem).FileName %>">
                                        <%# ((FileInfo)Container.DataItem).FileName %>
                                    </a>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

数据绑定部分

    DirectoryInfo ProviderFolder = new DirectoryInfo(strFolderPath);
    FileInfo[] BrochureList = ProviderFolder.GetFiles();
    if (BrochureList.Length > 0)
    {
        GrdVw_Download.DataSource = BrochureList;
        GrdVw_Download.DataBind();
    }

这是我的 gridview 标记,下面是这一行中 gridview 中的

<asp:GridView runat="server" id="GrdVw_Download">
                        <RowStyle cssclass="ItemStyle" />
                        <HeaderStyle cssclass="tableheader" horizontalalign="Left" />
                        <AlternatingRowStyle cssclass="AlternateItemStyle" horizontalalign="Left" />
                        <FooterStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" />
                        <Columns>
                            <asp:BoundField headertext="File name" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="FileName" />
                            <asp:BoundField headertext="File Size" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                dataformatstring="{0:#,### bytes}" datafield="Length" />
                            <asp:BoundField headertext="Extension" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center"
                                datafield="Extension" />
                            <asp:TemplateField headertext="Download Brochure" itemstyle-horizontalalign="Center"
                                headerstyle-horizontalalign="Center">
                                <ItemTemplate>
                                    <a href="?dl=<%# Encryptor.encrypt(((FileInfo)Container.DataItem).FullName) %>" 
                                    title="Download <%# ((FileInfo)Container.DataItem).FileName %>">
                                        <%# ((FileInfo)Container.DataItem).FileName %>
                                    </a>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

that's my gridview markup and below is the databinding part

    DirectoryInfo ProviderFolder = new DirectoryInfo(strFolderPath);
    FileInfo[] BrochureList = ProviderFolder.GetFiles();
    if (BrochureList.Length > 0)
    {
        GrdVw_Download.DataSource = BrochureList;
        GrdVw_Download.DataBind();
    }

in the gridview in this line <a href="?dl=<%# Encyptor.encrypt(((FileInfo)Container.DataItem).FullName) i get the error the post talks about. Where Encryptor encrypts the FilePath and markup generates a link to download the file
Edit Sorry:
*Solved it.* It is not FileName but just Name.Sorry again

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悸初 2024-11-07 16:38:43

这是因为'System.IO.FileInfo'不包含'FileName'的定义

您是否在寻找FullNameName

It's because 'System.IO.FileInfo' does not contain a definition for 'FileName'

Are you looking for FullName or Name perhaps?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文