File link path
I want to get all valid file records in seperate datagridview. Please assist to accomplish the task.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Jan 25, 2011, 10:06 AM EST
Please explain your query in detailed, so we can help you.
haris hussain3 reputationPosted Jan 25, 2011, 10:36 PM EST
private void CheckFileExists() { try { int successCount = 0; int failedCount = 0; string path = @"g:\t1"; string path2; for (int i = 0; i < dataGridView1.Rows.Count-1; i++) { path2 = path + dataGridView1.Rows[i].Cells[12].Value.ToString(); if (File.Exists(path2)) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Aqua; successCount++; for (int j = 0; j <= dataGridView2.Rows.Count; j++) { path2 = dataGridView1.Rows[j].Cells[12].Value.ToString(); j++; } } else { dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Red; CheckStatus = 1; if (CheckStatus == 1) { dataGridView1.Rows[i].Cells[12].Value.ToString(); } failedCount++; } } MessageBox.Show(successCount +" are correct & "+failedCount+" are incorrect file links in imported CSV file"); } catch { MessageBox.Show("Fatal error"); } }\\The above peace of code checks valid and invalid file paths. I want all records with valid file links in seperate grid view. > The background color of invalid file is Red while the background color of valid files is aqua. Since the count of invalid files is very high so, I badly need to segregate valid and invalid records