开发者

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

<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="Downl开发者_如何学Gooad 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


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

Are you looking for FullName or Name perhaps?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜