User1872364149 posted
Hi all, hope in your help.
With this asp net page upload file in C# I need to check for duplicates.
I accept 3 files in upload on the server.
After uploading the new 3 files on the server, I have tried to upload the same file 3 files now existing on the server.
For 3 files jpg existing on the server the response code on the Label
is incorrect because is :
File exist IMG0006A.jpg
Instead that :
File exist IMG0002A.jpg, IMG0005A.jpg, IMG0006A.jpg
What's the problem ?
Why if I have in the code foreach
in Label
the output is only for last existing file ?
My code below, thank you in advance for any help.
if (File.Exists(theFileName))
{
objDir = new DirectoryInfo(Server.MapPath("\\images\\));
objFI = objDir.GetFiles("*.*");
iFileCnt = 0;
if (objFI.Length > 0)
{
foreach (FileInfo file in objFI)
{
if (file.Name.ToString() == Path.GetFileName(theFileName))
{
lblFileList.Text = "File exist " + Path.GetFileName(theFileName);
iFileCnt += 1;
}
}
}
}