Hi kavithav,
Refer below code.
string existFile = "";
string[] arr1 = { "400005733.wav", "400006813.wav" };
string[] arr2 = { "400005733-b.doc", "400006813-b.doc" };
string[] arr3 = { "400005733-c.jpg", "400006813-c.jpg" };
string[] arr4 = { "400005733-d.mp3", "400006813-d.mp3" };
for (int i = 0; i < arr1.Length; i++)
{
for (int j = 0; j < arr2.Length; j++)
{
if (Path.GetFileNameWithoutExtension(arr2[j]).Replace("-b", "").ToUpper() == Path.GetFileNameWithoutExtension(arr1[i].ToUpper()))
{
existFile += arr2[j].Replace("-b", "") + ", ";
}
}
for (int j = 0; j < arr3.Length; j++)
{
if (Path.GetFileNameWithoutExtension(arr3[j]).Replace("-c", "").ToUpper() == Path.GetFileNameWithoutExtension(arr1[i].ToUpper()))
{
existFile += arr3[i].Replace("-c", "") + ", ";
}
}
for (int j = 0; j < arr4.Length; j++)
{
if (Path.GetFileNameWithoutExtension(arr4[j]).Replace("-d", "").ToUpper() == Path.GetFileNameWithoutExtension(arr1[i].ToUpper()))
{
existFile += arr4[i].Replace("-d", "") + ", ";
}
}
}
existFile = existFile.Remove(existFile.Length - 2, 2);
Response.Write(existFile);
Output
400005733.doc, 400005733.jpg, 400005733.mp3, 400006813.doc, 400006813.jpg, 400006813.mp3