C# 如何显示pdf和word文档的大小和图标?

C# 如何显示pdf和word文档的大小和图标?,c#,asp.net,css,C#,Asp.net,Css,我有包含word文档和pdf文件链接的网页。对于每个链接,我想显示文件大小和显示文件类型的图标 我想最好的方法是使用CSS?有人能给我举个例子说明怎么做吗 谢谢 创建链接html时,需要根据链接到的文件类型指定css类,例如: <a class="document" href="http://someurl.com/some/file/worddoc.doc" title="Your file size could go here">Word Doc</a> <a

我有包含word文档和pdf文件链接的网页。对于每个链接,我想显示文件大小和显示文件类型的图标

我想最好的方法是使用CSS?有人能给我举个例子说明怎么做吗


谢谢

创建链接html时,需要根据链接到的文件类型指定css类,例如:

<a class="document" href="http://someurl.com/some/file/worddoc.doc" title="Your file size could go here">Word Doc</a>
<a class="pdf" href="http://someurl.com/some/file/somefile.pdf">PDF File</a>
假设文件在磁盘上,您可以在代码隐藏中添加以下内容以获得文件大小。然后需要将其转换为更可读的内容,并将其添加到上面示例链接中的“title”属性中

System.IO.FileInfo info = new System.IO.FileInfo("filename");
long fileSizeInBytes = info.Length;

或者类似的东西。上面没有测试。

@Chris我已经添加了FileInfo行。
System.IO.FileInfo info = new System.IO.FileInfo("filename");
long fileSizeInBytes = info.Length;