File being used by a nother processor HTML file as attachement create file on the fly

I would like to generate a HTML File on the fly "Without the need to save it any where" as an email attachment, unfortunately I did not find away to do it that way , so I have used string builder to concatenate the HTML then I am saving that file to a folder on my asp.net app, then I attach the file from that folder to an email.

The problem is when I recreate the file then try to attach the same file I get the message that the file is being used by another processor.

appreciate your help in advance !
UKITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi UKIT;

When you are creating the file are you wrapping the File operations in a using block? If not try doing so, something like the following.

string fileName = "test.txt";

using (StreamWriter writer = new StreamWriter(fileName, true))
{
    // Your file operations here
    //  ....
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
UKITAuthor Commented:
I do indeed wrap it in using statement, the two things i have missed
1-is the "true" parameter which is why it is not closed.
2-i was giving the full path i.e. server.mappath...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.