File_RenameIfAlreadyExists = False

Jul 8, 2009 at 9:09 PM

When I set File_RenameIfAlreadyExists = True and upload a file with an identical name, the program realizes that a file with that name exists and then renames the incoming file. Works great.

When I set File_RenameIfAlreadyExists =False, on the INITIAL upload, it does not check for existing files with the same name. The feature only seems to work when I have MaxFiles set to greater than 1 and my list of recent uploads has a filename of the same name.

Is there another property that I can check during the INITIAL upload that will tell me if a filename with the same name already exists?

Eric

 

 

 

 

Aug 18, 2009 at 3:43 AM

Hi Eric

well i make the same question....

 

So I try to do that

 

if (fuImage.IsPosting)
            {
                SaveImage(ClientSessionInfo.ID);
            }  

 

if (fuImage.IsPosting)
{
       SaveImage();
}

private void SaveImage()
{
            
if (fuImage.PostedFile.Type == HttpPostedFileAJAX.fileType.image && fuImage.PostedFile.ContentLength == 2 * 1024)
    {
        FileInfo file = new FileInfo(fuImage.PostedFile.FileName);
        if (file.Exists)
        {
             file.Delete();
             fuImage.SaveAs("caminho", fuImage.PostedFile.FileName);
        }
        else
        {
             fuImage.SaveAs("caminho", fuImage.PostedFile.FileName);
        }
    }            
}  

where the fuImage is my uploadAjax, so when my fuImage is posting a file i call the method saveImage, than i validate my parameters and i create a FileInfo

of the System.IO library, and now i can chek if the file exist and do somthing

 

I hope that it help

[]'s

Luiz Augusto Franco

Brazil!