using LINQ syntax.
Feel free to comment.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FileSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DirectoryInfo root = new DirectoryInfo(".");
var files = from FileInfo f in root.GetFiles()
select new { FileName = f.Name, LengthFile = f.Length };
dataGridView1.DataSource = files.ToList();
}
}
}
No comments:
Post a Comment