TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Darshan Kshirasagar
NA
317
68.8k
When Execute Print cmd error Unable to initialize device PRN
Mar 26 2019 12:33 AM
Hi,
Using Command Prompt tried cmd "Print D:\PrintTest.txt" its worked proper, But the same command i am executing like below code through program it error "Unable to initialize device PRN" can anyone tell me the Issue why error ..?
private
string
ExecuteCMD(List ListCmd)
{
try
{
string
result;
using
(Process cmd =
new
Process())
{
cmd.StartInfo.FileName =
"cmd.exe"
;
cmd.StartInfo.RedirectStandardInput =
true
;
cmd.StartInfo.RedirectStandardOutput =
true
;
cmd.StartInfo.RedirectStandardError =
true
;
cmd.StartInfo.CreateNoWindow =
true
;
cmd.StartInfo.UseShellExecute =
false
;
cmd.Start();
foreach
(var sdata
in
ListCmd)
{
cmd.StandardInput.WriteLine(sdata);
}
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
result = cmd.StandardOutput.ReadToEnd();
cmd.WaitForExit();
cmd.Close();
}
return
result;
}
catch
(Exception ex)
{
MessageBox.Show(
"Error Occured "
+ ex.Message,
"Error"
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return
""
;
}
private
void
PrintData()
{
try
{
List objList =
new
List();
objList.Add(@
"cd /d "
+
"D:/"
);
objList.Add(@
"Print D:\PrintTest.txt"
);
textBox1.Text = ExecuteCMD(objList);
}
catch
(Exception ex)
{
MessageBox.Show(
"Error Occured "
+ ex.Message,
"Error"
, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Reply
Answers (
0
)
enable/disable of buttons, textboxes
Convert a number like (26032019) to date using c#