当前位置: 首页>>代码示例>>C#>>正文


C# StreamWriter.WriteString方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:kcjuntunen,项目名称:Redbrick-Addin,代码行数:55,代码来源:Program.cs


注:本文中的System.IO.StreamWriter.WriteString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。