-1

I have a datatable which contain a column Path of file. Now i want to filter file Path is exist or not.

DataTable.Select(File.Exists(ColumnsName))

Would you please help me how may i filter.

Sumit Kumar
  • 15
  • 1
  • 4

2 Answers2

0

You can filter datatable by file path column by checking existence using File.Exists

var result = dataTable.AsEnumerable().Where(r=>File.Exists(r.Field<string>("Path"));
Adil
  • 146,340
  • 25
  • 209
  • 204
0

DataSets are a pretty old concept in .NET so to use LINQ you need a bit of extra syntax:

dataTable.Rows.Cast<DataRow>().Select(row => File.Exists(row.Field<String>(columnName)))

This will return an IEnumerable<Boolean> that determines if the files exist.

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256