Hi PRA,
Please refer below code
C#
if (fuUpload.HasFile)
{
string file = string.Empty;
List<string> files = new List<string>();
List<string> duplicateFiles = new List<string>();
string postedFileName = Path.GetFileName(fuUpload.FileName);
string[] directoryForSearch = new string[] { "C", "D", "E" };
for (int k = 0; k < directoryForSearch.Length; k++)
{
DirectoryInfo drive = new DirectoryInfo(directoryForSearch[k] + ":\\");
DirectoryInfo[] folders = drive.GetDirectories("*.*");
for (int i = 0; i < folders.Length; i++)
{
FileInfo[] fileNames = folders[i].GetFiles("*.*");
if (fileNames.Length > 0)
{
for (int j = 0; j < fileNames.Length; j++)
{
files.Add(fileNames[j].DirectoryName + "\\" + fileNames[j].ToString());
}
}
}
}
int x = 0;
for (int l = 0; l < files.Count; l++)
{
if (postedFileName.ToLower() == files[l].Split('\\')[files[l].Split('\\').Length - 1].ToLower())
{
duplicateFiles.Add(files[l]); //You will get the duplicate files list with full path.
file += duplicateFiles[x] + "<br/>";
x++;
}
}
richTextBox1.Text = file;
}
Hope this works for you