The process cannot access the file

hi there in the first time the code runs its working o.k
the problem occur in the second time
i am geting this message :

The process cannot access the file 'c:\\temp.pdf' because it is being used by another process

static public void SendFirstEmails(CrystalDecisions.CrystalReports.Engine.ReportClass CreReport)
        {
          
            CreReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,"c:\\" + "temp" + ".pdf"); // here its falls from the second time

            CreReport.Dispose();            
          

        }

Open in new window

Tech_MenAsked:
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.

Tech_MenAuthor Commented:
sorry its accor here :
 CreReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,"c:\\" + "temp" + ".pdf");
0
Tech_MenAuthor Commented:
how can i know which process using the file and how can i dispose it ?
0
Miguel OzSoftware EngineerCommented:
Use Process Explorer
http://en.wikipedia.org/wiki/Process_Explorer
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

Check if CreReport object is holding it, if still exists it means that this class is not being disposed properly. (I mean at the caller level - the code that calls SendFirstEmails
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Tech_MenAuthor Commented:
this not helping me
0
Tech_MenAuthor Commented:
i dont see this object  CreReport
0
Miguel OzSoftware EngineerCommented:
In your code:
SendFirstEmails(CrystalDecisions.CrystalReports.Engine.ReportClass CreReport)

where is CreReport created, I hope that you are creating a new object every time you use it.
Why do you need to call dispose in this method?
I think what you need to is to use close instead of dispose to free resources. Dispose is only used when you no longer need the object at all.
when you say is not helping you. Did you download process explorer and run, please post a screen shot containing the information. we need to verify that your program or Crystal reports is not holding the file.
Note: Also check if this hotfix applies to you: (Meaning check you CR version before applying it)
Hotfix from crystal reports
http://support.businessobjects.com/communityCS/FilesAndUpdates/crnet11win_en.zip.asp 
fixed error" while exporting to PDF.

static public void SendFirstEmails(CrystalDecisions.CrystalReports.Engine.ReportClass CreReport) 
        { 
           
            CreReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,"c:\\" + "temp" + ".pdf");
 
            CreReport.Close();             
           
 
        }

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
Tech_MenAuthor Commented:
i will do a project sample an upload here
0
Tech_MenAuthor Commented:
the close didint help
0
Tech_MenAuthor Commented:
i found it the msg need to be dispose
thanks for trying to help
0
Tech_MenAuthor Commented:
its was a good lead
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
.NET Programming

From novice to tech pro — start learning today.