A better way of representing File Attachment into a list(c#3.0)

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-06-08T06:13:19Z Indexed on 2010/06/08 6:52 UTC
Read the original article Hit count: 141

Filed under:
|

I have written

List<Attachment> lstAttachment = new List<Attachment>();

            //Check if any error file is present in which case it needs to be send
            if (new FileInfo(Path.Combine(errorFolder, errorFileName)).Exists)
            {
                Attachment unprocessedFile = new Attachment(Path.Combine(errorFolder, errorFileName));
                lstAttachment.Add(unprocessedFile);
            }
            //Check if any processed file is present in which case it needs to be send
           if (new FileInfo(Path.Combine(outputFolder, outputFileName)).Exists)
            {
                Attachment processedFile = new Attachment(Path.Combine(outputFolder, outputFileName));
                lstAttachment.Add(processedFile);
            }

Working fine and is giving the expected output.

Basically I am attaching the file to the list based on whether the file is present or not.

I am looking for any other elegant solution than the one I have written.

Reason: Want to learn differnt ways of representing the same program.

I am using C#3.0

Thanks.

© Stack Overflow or respective owner

Related posts about c#3.0

Related posts about refactoring