Problem with code
-
Hello, I am using VS 2005 and following is the code: Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fp As StreamWriter Dim line As String Dim filename As String = System.Guid.NewGuid.ToString & ".Txt" Try fp = File.CreateText(Server.MapPath(filename)) line = "Normal Text" & Chr(27) & "E" & " Bold Text" & Chr(27) & "F" fp.WriteLine(line) line = "Normal " & Chr(27) & "S 0" & " It should be superscript" & Chr(27) & "T" fp.WriteLine(line) fp.WriteLine(Chr(27) & "4" & " Italic Mode" & Chr(27) & "5") ' Italic mode fp.WriteLine(Chr(20) & " or it should be superscript " & Chr(20) & "Normal") fp.WriteLine(Chr(15) & "Girish Kumar Sharma" & Chr(18)) ' condensed mode 'fp.WriteLine(Chr(12)) ' Page Eject fp.Close() Catch err As Exception err.ToString() Finally End Try Dim fpforbat As StreamWriter Dim strFilePath As String = "c:\\temp\\" & System.Guid.NewGuid.ToString & ".Bat" fpforbat = File.CreateText(strFilePath) Dim x As String = "Type " & Chr(34) & Server.MapPath(filename) & Chr(34) & " > PRN" fpforbat.WriteLine(x) fpforbat.Close() 'Dim strFilePath As String = "c:\\temp\\test.bat" Dim psi As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("cmd.exe") psi.UseShellExecute = False psi.RedirectStandardOutput = True psi.RedirectStandardInput = True psi.RedirectStandardError = True psi.WorkingDirectory = "c:\\temp\\" Dim proc As System.Diagnostics.Process = System.Diagnostics.Process.Start(psi) Dim strm As System.IO.StreamReader = System.IO.File.OpenText(strFilePath) Dim sout As System.IO.StreamReader = proc.StandardOutput Dim sin As System.IO.StreamWriter = proc.StandardInput While strm.Peek() <> -1 sin.WriteLine(strm.ReadLine()) End While strm.Close() Dim stEchoFmt As String = "# {0} run successfully. Exiting" sin.WriteLine(String.Format(stEchoFmt, strFilePath)) sin.WriteLine("EXIT") proc.Close() sin.Close() sout.Close() 'File.Dele
-
Hello, I am using VS 2005 and following is the code: Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fp As StreamWriter Dim line As String Dim filename As String = System.Guid.NewGuid.ToString & ".Txt" Try fp = File.CreateText(Server.MapPath(filename)) line = "Normal Text" & Chr(27) & "E" & " Bold Text" & Chr(27) & "F" fp.WriteLine(line) line = "Normal " & Chr(27) & "S 0" & " It should be superscript" & Chr(27) & "T" fp.WriteLine(line) fp.WriteLine(Chr(27) & "4" & " Italic Mode" & Chr(27) & "5") ' Italic mode fp.WriteLine(Chr(20) & " or it should be superscript " & Chr(20) & "Normal") fp.WriteLine(Chr(15) & "Girish Kumar Sharma" & Chr(18)) ' condensed mode 'fp.WriteLine(Chr(12)) ' Page Eject fp.Close() Catch err As Exception err.ToString() Finally End Try Dim fpforbat As StreamWriter Dim strFilePath As String = "c:\\temp\\" & System.Guid.NewGuid.ToString & ".Bat" fpforbat = File.CreateText(strFilePath) Dim x As String = "Type " & Chr(34) & Server.MapPath(filename) & Chr(34) & " > PRN" fpforbat.WriteLine(x) fpforbat.Close() 'Dim strFilePath As String = "c:\\temp\\test.bat" Dim psi As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("cmd.exe") psi.UseShellExecute = False psi.RedirectStandardOutput = True psi.RedirectStandardInput = True psi.RedirectStandardError = True psi.WorkingDirectory = "c:\\temp\\" Dim proc As System.Diagnostics.Process = System.Diagnostics.Process.Start(psi) Dim strm As System.IO.StreamReader = System.IO.File.OpenText(strFilePath) Dim sout As System.IO.StreamReader = proc.StandardOutput Dim sin As System.IO.StreamWriter = proc.StandardInput While strm.Peek() <> -1 sin.WriteLine(strm.ReadLine()) End While strm.Close() Dim stEchoFmt As String = "# {0} run successfully. Exiting" sin.WriteLine(String.Format(stEchoFmt, strFilePath)) sin.WriteLine("EXIT") proc.Close() sin.Close() sout.Close() 'File.Dele
Wow - what a nightmare this is. What are you trying to do ? Does this cause things to print on the print ? Why do you want to write code that prints stuff on the server ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
Wow - what a nightmare this is. What are you trying to do ? Does this cause things to print on the print ? Why do you want to write code that prints stuff on the server ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
Sir, Thanks for your reply. From the above code, i am creating a formated text file and one batch file which will be print the formated text file by using dos mode i.e. > PRN; but sir, problem is that if i wish to delete the formated and/or batch file, after run the code, i am not able to do so. Regards Girish Sharma
-
Sir, Thanks for your reply. From the above code, i am creating a formated text file and one batch file which will be print the formated text file by using dos mode i.e. > PRN; but sir, problem is that if i wish to delete the formated and/or batch file, after run the code, i am not able to do so. Regards Girish Sharma
I repeat. Why do you want to emit a printout on the server ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
I repeat. Why do you want to emit a printout on the server ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
I do'nt know, how to create the text file on client's machine; and what is another way to get the DOS mode (which runs faster) printing of a text file by asp.net, so please guide/help me in this regard. Regards Girish Sharma
The thing Christian wants to point out is that your application will use the printer installed on the server where you application is running. It means, every time the printout will be generated by the printer installed on the server, not on the machine from where you are accessing the web page.
-
The thing Christian wants to point out is that your application will use the printer installed on the server where you application is running. It means, every time the printout will be generated by the printer installed on the server, not on the machine from where you are accessing the web page.
At the first stage if it runs on server machine and printer; then my question will be how to access and client's printer to get printout. Actually, this is running fine on server printer but if i remove the comment from any of last two line i.e. 'File.Delete(Server.MapPath(".") & "\" & filename) 'File.Delete(strFilePath) then no print out comes on the printer. Please help me. Regards Girish Sharma
-
At the first stage if it runs on server machine and printer; then my question will be how to access and client's printer to get printout. Actually, this is running fine on server printer but if i remove the comment from any of last two line i.e. 'File.Delete(Server.MapPath(".") & "\" & filename) 'File.Delete(strFilePath) then no print out comes on the printer. Please help me. Regards Girish Sharma
That may be because the print command hasn't finished when you delete the file but it isn't important if you want to print on the client machine anyway. Look into the javascript function window.print if you need to print client side.
-
At the first stage if it runs on server machine and printer; then my question will be how to access and client's printer to get printout. Actually, this is running fine on server printer but if i remove the comment from any of last two line i.e. 'File.Delete(Server.MapPath(".") & "\" & filename) 'File.Delete(strFilePath) then no print out comes on the printer. Please help me. Regards Girish Sharma
None of this matters, you moron. You're printing on the server. Don't you read ? If you want to print on the client, none of the hideously ugly code you posted, will do that, nor is it possible to print in ASP.NET in any direct way through your code behind. Buy a basic ASP.NET book and read it, it's clear you have no idea what server side code is.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
None of this matters, you moron. You're printing on the server. Don't you read ? If you want to print on the client, none of the hideously ugly code you posted, will do that, nor is it possible to print in ASP.NET in any direct way through your code behind. Buy a basic ASP.NET book and read it, it's clear you have no idea what server side code is.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
Sir, I created the required formated text file with the help of above code. Now i wish to get print on Line Matrix Printer in DOS mode; so i read that it can be achieved by run a batch file. If it is not possible with the above code then; how do i print (DOS Mode) the generated text file at client machine on the click of a button in the web page, with the help of window.print and/or by any other mean please. If you please provide me any link i shall be highly thankful to you. Best Regards Girish Sharma