PLease help getting error as The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process

Dear All,

I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End 

I generated local mode report but as there was no printing option available . I assign printing feature to button click by exporting the data to EMF format and print

Now when I run it through IDE VS2005 then it does not show any error.

But when I run in through IIS in intranet it showing me this error

 

The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process

Where I am going wrong please guide me.

 

 

 

Code used are

 

Button click code

 

protected void Btnprint_Click(object sender, EventArgs e)

    {

        LocalReport report = new LocalReport();

        vw_tranTableAdapter da = new vw_tranTableAdapter();

        report.ReportPath = @"D:\Inventracksys\inventorytracking\Vendorwisereport.rdlc";

        report.DataSources.Add(new ReportDataSource("tran_vw_tran", da.GetDataByvendor(RadioButtonList1.SelectedValue, DropDownListvendor.SelectedValue)));

        export(report);

        m_currentpageindex = 0;

        Print();

    }

 

Creating stream as

 

private Stream CreateStream(string name, string filenameextension, Encoding encoding, string mimetype, bool willseek)

    {

        Stream stream = new FileStream(@"D:\Inventracksys\Inventorytracking " + name + "." + filenameextension, FileMode.Create );

        //Stream stream = new FileStream(name + "." + filenameextension, FileMode.Create);

        m_streams.Add(stream);

        return stream;

    }

 

Exporting to EMF

 

    private void export(LocalReport report)

    {

        string deviceInfo = "<DeviceInfo>" + "  <OutputFormat>EMF</OutputFormat>" + "  <PageWidth>9in</PageWidth>" + "  <PageHeight>12in</PageHeight>" + "  <MarginTop>0.25in</MarginTop>" + "  <MarginLeft>0.25in</MarginLeft>" + "  <MarginRight>0.25in</MarginRight>" + "  <MarginBottom>0.25in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; m_streams = new List<Stream>(); report.Render("Image", deviceInfo, CreateStream, out warnings);

        foreach (Stream stream in m_streams) stream.Position = 0;

 

    }

Printhandler event

 

 

    private void PrintPage(object sender, PrintPageEventArgs ev)

    {

        Metafile pageImage = new

        Metafile(m_streams[m_currentpageindex ]);

        ev.Graphics.DrawImage(pageImage , ev.PageBounds);

        m_currentpageindex++;

        ev.HasMorePages = (m_currentpageindex < m_streams.Count);    }

 

printing option

 

 

    private void Print()

    {

        const string printerName =

           "Microsoft Office Document Image Writer";

        if (m_streams == null || m_streams.Count == 0)

            return;

        PrintDocument printDoc = new PrintDocument();

        printDoc.DefaultPageSettings.Landscape = true; 

        printDoc.PrinterSettings.PrinterName = printerName;

       // lblerrmsg.Text = printDoc.PrinterSettings.PrinterName;    

      

       

        if (!printDoc.PrinterSettings.IsValid)

        {

            string msg = String.Format(

               "Can't find printer \"{0}\".", printerName);

            //MessageBox.Show(msg, "Print Error");

            lblerrmsg.Text = "Print Error";

            return;

        }

        

        printDoc.PrintPage += new PrintPageEventHandler(PrintPage);

        printDoc.Print();

    }

    public void Dispose()

    {

        if (m_streams != null)

        {

            foreach (Stream stream in m_streams)

                stream.Close();

            m_streams = null;

        }

    }

 

Now when I run it through IDE VS2005 then it does not show any error.

But when I run in through IIS in intranet it showing me this error

 

The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process

Where I am going wrong please guide me.

Thanks 

 

 

0
mohdimranabdulaziz
4/3/2007 2:32:12 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

0 Replies
884 Views

Similar Articles

[PageSpeed] 10
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

PLease help getting error as The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process #2
Dear All, I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End  I generated local mode report but as there was no printing option available . I assign printing feature to button click by exporting the data to EMF format and print Now when I run it through IDE VS2005 then it does not show any error. But when I run in through IIS in intranet it showing me this error   The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process Where I am going wrong pl...

Cannot copy assembly 'DotNetNuke' to file '<assemly>'. The process cannot access the file because it is being used by another process.
I am in the process of creating a new module and I keep running into this problem. This happens every time I try to build the project. SOMETIMES I can get it working again by deleting the previously generated assemblies and reopening the project, but that doesn't always work and I'd like for the problem not to be there in the first place. My new module project is located at \DotNetNuke\DesktopModules\NewModule The build path for the assembly is set to ..\..\bin which is \DotNetNuke\Bin I am also using a project reference rather than an assembly reference so that shouldn't be the p...

The process cannot access the file '.....' because it's being used by another process
In VB6.0 I was using API calls for checking that a process has finished and then continue with other steps:       var_process_number = Shell("wzunzip.exe -o " & """" & fld_ZIP_file_name & """" & " " & """" & fld_import_path & """", vbMinimizedNoFocus)       'wait until the uncompressing is over         var_process_handle = OpenProcess(&H100000, True, var_process_number)         WaitForSingleObject var_process_handle, -1         CloseHandle var_process_handle In ASP....

Could not write to output file '...\obj\Debug\abc.dll" -- 'The process cannot access the file because it is being used by another process'
I use VS2003. Recently I keep getting this error when building the solution. Any idea how to fix it?? THANKS!  Could not write to output file '...\obj\Debug\abc.dll" -- 'The process cannot access the file because it is being used by another process' Close any other projects that link to this dll (i.e., any extra Visual Studio instances).  Also, try closing the app-- If you are running/debugging the project that references this dll, then you may be using that dll.  ---------------------------------------MCP - Web Based Client Development .NET 2.0 Thanks f...

The process cannot access the file '' because it is being used by another process.
 Hai guys..Write now i am designing an event calendar . I am having an error message while trying to delete an event with images.. The event detail page is view with event details and the image under the event (i.e) photogallery is shown. while i am trying to delete the event with image it show an error message like "The process cannot access the file '<filepathname>' because it is being used by another process." . I have listed my code here.. 1 protected void gvAdminEventDetail_RowDeleting(object sender, GridViewDeleteEventArgs e) 2 { 3 ...

(urgent) The process cannot access the file '[filename]' because it is being used by another process.
For some reason my users are getting the following error in production: "System.IO.IOException: The process cannot access the file 'D:\[omitted]\TestingCenter\Xml\TestPlans\dbeckett\20071204_4' because it is being used by another process." This is occurring in my production environment, but did not occur in development or staging environments. Here is my code:string path = ConfigurationManager.AppSettings["xmlPath"];_modules = new Modules(); ClearLineItems();if (Directory.Exists(path + CurrentUser.Username)) { path += CurrentUser.Username + "\\";...

IOException: The process cannot access the file 'filename' because it is being used by another process
Hi everyone,I'm having some difficulty with my File upload and File delete processes.For the Upload, I do like:sTempName = path + FileUpload1.FileName;FileUpload1.PostedFile.SaveAs(sTempName); //sTempName = C:\Inetpub\vhosts\myfile.jpgIt works fine on my local machine, but once I upload it to my remote server, I sometimes (about 1 in 8 times) hit this exception:System.IO.IOException: The process cannot access the file 'C:\Inetpub\vhosts\myfile.jpg' because it is being used by another process.   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)   at Sy...

System.IO.IOException: The process cannot access the file '' because it is being used by another process.
I am getting the above mentioned error. My code is as below and the stack trace also follows. I am not trying to open the file or copy or move, i just want to attach it to an email. Dim _today As Date Dim _dayNumber As Integer Dim _wcDayNumber As Integer Dim _stepDownVal As Integer Dim _negated As Integer Dim _wcDay As Date Dim wc As String Dim _filename As String Dim _foldername As String _today = Date.Today _dayNumber = Date.Today.DayOfWeek _wcDayNumber = 1 _stepDown...

SqlBulkCopy & problem: The process cannot access the file '' because it is being used by another process.
I use the SQLBulkCopy class to insert data from a excel file to SQL Server table.             Dim OleDbConn As OleDbConnection = New OleDbConnection(sExcelConnectionString)            Dim OleDbCmd As OleDbCommand = New OleDbCommand(("SELECT * FROM " & sWorkbook), OleDbConn)            OleDbConn.Open()            Dim dr As OleDbDataReader = OleDbCmd.ExecuteReade...

System.IO.IOException: The process cannot access the file 'xxxx.pdf' because it is being used by another process.
I have a basic vb.net form that collects some data, allows users to add attachments, and when they click submit, generates an email that includes the data and the attachments that were uploaded to the server. To keep my server clean, after the email is sent, I want to remove the attachments... However, I keep getting an error that says it can't access the file because it is being used by another process.  I can either send the email or delete the file, but can't get the two to work together... Any suggestions? my code behind...        Protected S...

(VB) The process cannot access the file 'C:something/something.jpg' because it is being used by another process.
I found articles about this error but none mentioned the situation where the very first action the code takes (or so I believe) shuts down the program as if something else had previously happened to tie up the file. The code below is very short, two controls on the ASPX page and only two lines of code behind.  The first one causes the error: PictureUploadControl.SaveAs(Server.MapPath("~/images/ORIGINAL") & PictureUploadControl.FileName) Please find, if possible, in the code below what error is causing a denial of file access.  Thank you for your help. The an...

Help
Hi, I have an xml file that I open, make changes to, save and close. If I open the file again, make more changes and save it I get the following error: The process cannot access file "C:\...\DataFile.xml" because it is being used by another process. I can't determine what the other process is. When saving, I open the file using a reader: XmlTextReader reader = new XmlTextReader(@"DataFile.xml"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); reader.Close(); //make the updates to the xml attributes... Then I use the XMLTextWr...

Can not access file 'filename' because it is being used by another process
I'm getting the following error on my web servers occassionally and the site is inaccessible until I reboot. It only happens occassionally and I can't force the duplication of it. The file is one of the DLLs that the app is trying to access. Is anyone familiar with this? Server Error in '/' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify you...

Process can't access file because it is being used by another process
Hi I've to extract a zip file and delete that zip file. When i extract zip file, the file is extracted successfully, but when i try to delete the file, it throws the Exception "Process can't access file because it is being used by another process". Can some one solve my problem. Thanks in advance.ZIA UR REHMAN how are you extracting the file? if you're using a library, remember to close the zipfile before you try deleting it. yeah this was the problems... thanks alot for the help. i really appreciate. ThaksZIA UR REHMAN...

Web resources about - PLease help getting error as The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process - asp.net.web-forms

Resources last updated: 12/23/2015 5:35:29 PM