Click here to Skip to main content
15,746,302 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

i have created small web application, from my web application i ll write some text into in text file(notepad file)after that
i ll print that text file from my web application itself,then it will be print to default printer..
its works well in my local pc, but when i configure this web application into client pc through IIS its not working well,
only i can write my text into text file(notepad file), but that text file is not printing..

this is the code for that

private void ReadFile()
            string path;
            path = Server.MapPath("~/Temp_Image/");
            string docName = "Truevalue.txt";
           // string docPath = @"C:\sample\";
            string docPath = path;
            printDocument1.DocumentName = docName;
            using (FileStream stream = new FileStream(docPath + docName, FileMode.Open))
            using (StreamReader reader = new StreamReader(stream))
                stringToPrint = reader.ReadToEnd();
Updated 14-Aug-11 23:24pm

You will not have access to the printer you are trying to print on.
Share this answer
Sergey Alexandrovich Kryukov 15-Aug-11 22:40pm    
Exactly, my 5. I added some words to it, please see.
Abhinav S 16-Aug-11 1:07am    
Thank you SA.
It makes no sense, as Abhinav explained to you. To start, there is no such thing as "notepad file". But there is no a problem here: a user can print any content you provide just fine. Anyway, users would not appreciate such annoying "help" if some Web application is trying to print on their printer. What's the Web browser's "Print…" menu items for?

Share this answer
Abhinav S 16-Aug-11 1:06am    
My 5 too. :)
Sergey Alexandrovich Kryukov 16-Aug-11 1:14am    
Thank you, Abhinav.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900