-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.

2
  • You search it in a specific column? Commented Mar 2, 2016 at 7:10
  • Yes, one column of that table contains file path Commented Mar 2, 2016 at 7:12

2 Answers 2

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"));
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.