“System.IO.FileInfo”不包含“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="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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为'System.IO.FileInfo'不包含'FileName'的定义
您是否在寻找
FullName
或Name
?It's because 'System.IO.FileInfo' does not contain a definition for 'FileName'
Are you looking for
FullName
orName
perhaps?