I uses this code to get all mdf files in a folder
string[] Dbfiles = Directory.GetFiles(c.Path + c.CompanyName + c.ProgramTitle, "*.mdf", SearchOption.TopDirectoryOnly); MessageBox.Show(Dbfiles[Dbfiles.Length-1]);
works fine on windows 7 and 10 x64 but it gives me Index was outside the bounds exception on windows 7 x32 i tried
MessageBox.Show(Dbfiles[0]);
and other stuff but it doesn't work i uses dot net framework 3.5
ForEach fix it
foreach (string file in Dbfiles)
{
if (string.IsNullOrEmpty(file))
{
//escape
continue;
}
else
{
c.MdfFilePath = file;
break;
}
}