in my program i have a datagridview,populated with 2 columns.
frist columns contains value like as filename.ext
second column contains size of this file.
now,i need to compare if file listed in column are present or not in a selected folder(selected by openfolder dialog)
i think have to use
DirectoryInfo di = new DirectoryInfo(fldChk.SelectedPath);
FileInfo[] rgFiles = di.GetFiles("*.*");
foreach (FileInfo file in rgFiles)
{ //do there
i think use 2 array list,then add in frist filename,in second filesize.but is only supposition and for folder with many file,is very slow process.
what are best way to do thath?
You don’t need to create a FileInfo object to detect whether a file at a particular path exists. Just use the System.IO.File.Exists method. If the path in the first column is a relative path, you’ll have to prepend the absolute path to the path in the column before you call the Exists method.