【发布时间】:2020-09-15 14:44:46
【问题描述】:
如何在 C# 中打印文本文件?在控制台应用程序中。
这是我发现的:msdn sample 和这个 stackoverflow:answer is the msdn sample
链接中的代码适用于 Windows 窗体应用程序,不适用于控制台应用程序。
这是我发现的:
string fileName = @"C:\data\stuff.txt";
ProcessStartInfo startInfo;
startInfo = new ProcessStartInfo(fileName);
if (File.Exists(fileName))
{
int i = 0;
foreach (String verb in startInfo.Verbs)
{
// Display the possible verbs.
Console.WriteLine(" {0}. {1}", i.ToString(), verb);
i++;
}
}
startInfo.Verb = "print";
Process.Start(startInfo);
既然你说这个问题是题外话而且不相关,这里是我想要学习的链接:This is documentation of the .Net framework 这就是我问这个问题的原因,我正在尝试了解各种.Net 类的使用。
【问题讨论】:
-
你写过代码吗?你试过什么?有什么错误吗?
-
你用谷歌搜索了吗?
-
您必须解释为什么这些链接不适合您。如果你不这样做,你的问题可能会被当作骗子关闭
-
该链接适用于 winform 而不是控制台应用程序
-
您可以在控制台应用程序中使用
System.Windows.WinForms...