473,804 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PLease help getting error as The process cannot access the file 'D:\Inventracks ys\Inv

29 New Member
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:\Inventracks ys\Inventorytra cking Vendorwiserepor t_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_tranTableAda pter da = new vw_tranTableAda pter();
report.ReportPa th = @"D:\Inventrack sys\inventorytr acking\Vendorwi sereport.rdlc";
report.DataSour ces.Add(new ReportDataSourc e("tran_vw_tran ", da.GetDataByven dor(RadioButton List1.SelectedV alue, DropDownListven dor.SelectedVal ue)));
export(report);
m_currentpagein dex = 0;
Print();
}

Creating stream as
private Stream CreateStream(st ring name, string filenameextensi on, Encoding encoding, string mimetype, bool willseek)
{
Stream stream = new FileStream(@"D: \Inventracksys\ Inventorytracki ng " + name + "." + filenameextensi on, FileMode.Create );
//Stream stream = new FileStream(name + "." + filenameextensi on, FileMode.Create );
m_streams.Add(s tream);
return stream;
}

Exporting to EMF

private void export(LocalRep ort report)
{
string deviceInfo = "<DeviceInf o>" + " <OutputFormat>E MF</OutputFormat>" + " <PageWidth>9i n</PageWidth>" + " <PageHeight>12i n</PageHeight>" + " <MarginTop>0.25 in</MarginTop>" + " <MarginLeft>0.2 5in</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(objec t sender, PrintPageEventA rgs ev)
{
Metafile pageImage = new
Metafile(m_stre ams[m_currentpagein dex ]);
ev.Graphics.Dra wImage(pageImag e , ev.PageBounds);
m_currentpagein dex++;
ev.HasMorePages = (m_currentpagei ndex < 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.Defaul tPageSettings.L andscape = true;
printDoc.Printe rSettings.Print erName = printerName;
// lblerrmsg.Text = printDoc.Printe rSettings.Print erName;


if (!printDoc.Prin terSettings.IsV alid)
{
string msg = String.Format(
"Can't find printer \"{0}\".", printerName);
//MessageBox.Show (msg, "Print Error");
lblerrmsg.Text = "Print Error";
return;
}

printDoc.PrintP age += new PrintPageEventH andler(PrintPag e);
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:\Inventracks ys\Inventorytra cking Vendorwiserepor t_1.emf' because it is being used by another process
Where I am going wrong please guide me.
Thanks
Apr 3 '07 #1
0 1805

Sign in to post your reply or Sign up for a free account.

Similar topics

2
303
by: david | last post by:
I am calling a dll in my C# project, when I try to access its log file, I got error " The process cannot access the file "xxxxxxx" because it is being used by another process. ". I suspect the dll doesn't close its log file immediately, but I can not do nothing about it. Since I can open the log file in File explorer(when I tried to delete it, I got a file share violation, that is for sure), I think I could open and read the file in my...
2
17763
by: Amanda | last post by:
From a guy in Microsoft newsgroups: | In *comp.databases.ibm-db2* there are always IBM guys | from the Toronto labs on line.Post with the | -for the love of god please help- | line and I'm sure you'll get their attention. | Their usually very good:) So here's my transplanted post ==========================================
4
2399
by: news.microsoft.com | last post by:
I need some help here guys.... i have been simply trying to delete a file from the webserver using asp.net using the following code. System.IO.File.Delete(FullPath); however the error message i get is the following The process cannot access the file "e:\inetpub\wwwroot\client_dev\brands\Product_images\1450.jpg" because it is
11
3758
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very simple batch file (echo hello world) and was trying to retrieve the standard output but every time I run the code it returns ExitCode as 1.
5
8728
by: ZWeng | last post by:
I created a windows service using FileSystemWatcher to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder. If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOException: The process cannot...
1
3660
by: =?Utf-8?B?UGllcnJl?= | last post by:
Hello, I have an simle application that uses a referenced library of my own. It's been a year now that I have no problems until a few days. Here is the details of my problem: The library referenced by the main application compiles properly. When I compile the main application, I have the following message: Cannot copy assembly 'MyLib' to file 'D:\Development\Projects\MyClent\MyLib.dll'. The requested operation cannot be performed...
4
2218
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I wanted to move my work and needed to place it on the server. Using VS 2005 , went to BUILD -Publish Web Site Checked the box for :: Alow this precompiled site to be updatable.
33
11870
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM). I understand that when the service starts, no user may be logged in, but that's ok, as the app I am monitoring can only be run by a logged in user. Do I need to use WMI to get the user context of Explorer.exe or is there a...
4
4532
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst child apps of an IIS application and can be used by multiple users during the application life cycle and for multiple page loads for the same or different page under a root application. What I don't understand and need to know is whether that...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.