此代码的说明 [英] Explanation for this code
本文介绍了此代码的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请给我解释此代码.在此代码中,gvfiles是gridview的名称.
Please give me the explanation for this code. In this code gvfiles is the name of a gridview.
private void BindData()
{
var files = Directory.GetFiles(Server.MapPath("~/Files"));
gvFiles.DataSource = from f in files
select new
{
FileName = Path.GetFileName(f),
FilePath = f
};
gvFiles.DataBind();
}
推荐答案
如果您想在该领域获得成功,您确实需要学习如何阅读代码和进行研究.在MSDN上可以轻松找到此处的所有内容.
此代码获取给定目录中所有文件的收集文件路径.然后,它使用LINQ查询创建一个投影,其中包含每个文件的文件名和路径,并将其分配给网格的数据源.
If you want to succeed in this field you really need to learn how to read code and research. Everything here is easily found on MSDN.
This code is getting a collection file paths for all files in the given directory. It is then creating a projection using a LINQ query that contains the filename and path for each of the files and assigning it to the datasource for the grid.
这篇关于此代码的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文