This project is read-only.


Jul 31, 2010 at 7:08 AM

Hi all,

I am saving attachments from the emails in a folder. If a file already exists with the name same as the attachment file, the method DecodeData(path) appends "0" to filename and saves it.

Is there any way to replace the files in the folder with the attachment file if the file already exists in the folder?,


Is there any way we could find out if the attachment saved to the folder is appended with "0" in its name?

Thanks in advance.



Jul 31, 2010 at 4:01 PM

I think that C#Mai munt not be responsible for this functionality.
You can add your library such as...

public static String GetFileName(String folderPath, String fileName)
    Int32 index  = 0;
    String newFileName = String.Format("{0}\\{1}",  folderPath, fileName);
    while (true) 
         if (File.Exists(newFileName) == true)
              newFileName = String.Format("{0}\\{1}{2}{3}",  folderPath, fileName, index, Pah.GetExtension(fileName)); 
    return newFileName;


Aug 2, 2010 at 5:24 AM

Hi Higty,

Thank you very much for guiding me for an outstanding method for file checking and generating a new file name.

Thanks a lot.