Try placing the file in the App_Data folder
Main Topics
Browse All TopicsI dveloped an application using asp.net , the application generate auto number with the date and time then store them in text file in order to print them by default printer in the machine , So when I am trying to save data in the text file it shows the following error :
The process cannot access the file 'd:\inetpub\wwwroot\WebSit
This problem appear only when I run my project on ( IIS ) and its work fine when Its run in Web developer 2005 or Visual Studio 2005 with no error .
please can any one knows what is the problem
best regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
OK, hi,
To avoid beating around the bush any longer go and install http://ccollomb.free.fr/un
Thi
After several expperments i found the following :
My application is send the data to text file before printing So every time I Push on print button it sends data to the text but printing code is not working in IIS but ( work in devloper 2005) then its cant connect to printer so the orders for printing is stay in queue and finally that message appear which is say the process is used by another process .
When I disable print code every thing is fine and the data is display on the screen . when I use the below code it give me the privious message and the Puzzling thing is every thing is running when i run the application using web developer but its not working on ( IIS ) I cannot connect to my defalt printer .
Can any one help me with printing code .
Here is the description of PrintDocument from MSDN: http://msdn.microsoft.com/
" Defines a reusable object that sends output to a printer, when printing from a Windows Forms application."
So the key point here is Windows Forms, this class was not meant to be used in ASP.NET, but if you use it it will print only on the server.
So back to your code, I noticed that you are not specifying the printer name, so the default printer is being used. Is that what you want? Also where are you opening the web form from? Is it the same machine where IIS is installed? Are you using a local printer or network printer?
Business Accounts
Answer for Membership
by: squillmanPosted on 2008-07-09 at 14:17:05ID: 21968481
Probably because IIS has the file locked. Do you have the option of saving the file to a different directory outside of the document root?