本文整理汇总了C#中System.IO.StreamWriter.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriter.WriteString方法的具体用法?C# StreamWriter.WriteString怎么用?C# StreamWriter.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamWriter
的用法示例。
在下文中一共展示了StreamWriter.WriteString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// This program is used at compile-time by the NSIS Install Scripts.
/// It copies the file properties of an assembly and writes that info a
/// header file that the scripts use to make the installer match the program
///
/// I got it from <http://stackoverflow.com/questions/3039024/nsis-put-exe-version-into-name-of-installer#3040323>
/// </summary>
static void Main(string[] args)
{
try {
string inputFile = args[0];
string outputFile = args[1];
System.Diagnostics.FileVersionInfo fileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(inputFile);
using (TextWriter writer = new StreamWriter(outputFile, false, Encoding.Default)) {
writer.WriteLine("!define VERSION \"" + fileInfo.FileVersion + "\"");
writer.WriteLine("!define DESCRIPTION \"" + fileInfo.FileDescription + "\"");
writer.WriteLine("!define COPYRIGHT \"" + fileInfo.LegalCopyright + "\"");
writer.Close();
}
string xmlFile = "version.xml";
XmlWriterSettings xws = new XmlWriterSettings();
xws.CloseOutput = true;
xws.ConformanceLevel = ConformanceLevel.Document;
xws.Indent = true;
xws.WriteEndDocumentOnClose = true;
using (XmlWriter writer = XmlWriter.Create(xmlFile)) {
writer.WriteStartDocument();
writer.WriteStartElement("RedBrick");
writer.WriteStartElement("version");
writer.WriteString(fileInfo.FileVersion);
writer.WriteEndElement();
writer.WriteStartElement("url");
writer.WriteString(@"file://\\AMSTORE-SVR-02\shared\shared\general\RedBrick\InstallRedBrick.exe");
writer.WriteEndElement();
string update_message = string.Empty;
using (TextReader tr = new StreamReader(Properties.Settings.Default.MessagePath)) {
update_message = tr.ReadToEnd();
}
writer.WriteStartElement("message");
writer.WriteString(update_message);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
} catch (Exception e) {
Console.WriteLine(e.Message + "\n\n");
Console.WriteLine("Usage: GetAssemblyInfoForNSIS.exe MyApp.exe MyAppVersionInfo.nsh\n");
}
}