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


C# StreamReader.Write方法代码示例

本文整理汇总了C#中System.IO.StreamReader.Write方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Write方法的具体用法?C# StreamReader.Write怎么用?C# StreamReader.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StreamReader的用法示例。


在下文中一共展示了StreamReader.Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            string fileIn = null;
            string fileOut = null;
            int exitCode = 0;
            FileFormat input_type = FileFormat.Auto;
            if (args.Length == 0)
            {
                usageHelp();
                exitCode = 1;
            }
            else
            {
                foreach (string arg in args)
                {
                    if (arg.StartsWith("-", StringComparison.InvariantCulture) ||
                        arg.StartsWith("/", StringComparison.InvariantCulture)
                        )
                    {
                        #region Process options

                        string[] option = arg.Substring(1).Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                        string value = string.Empty;
                        if (option.Length == 2)
                            value = option[1].Trim();

                        switch (option[0].ToLowerInvariant())
                        {
                            case "hex":
                                input_type = FileFormat.Hex;
                                break;
                            case "bin":
                                input_type = FileFormat.Binary;
                                break;
                            case "jam":
                                input_type = FileFormat.Jam;
                                break;
                            case "mcu":
                                #region Set PIC type
                                switch (value.ToUpperInvariant())
                                {
                                    case "PIC24FJ256":
                                        Memory = new byte[256 * 1024];
                                        break;
                                    case "PIC24FJ128":
                                        Memory = new byte[128 * 1024];
                                        break;
                                    default:
                                        Console.WriteLine(string.Format("Unknown -mcu {0}", value));
                                        exitCode = 1;
                                        break;
                                }
                                break;
                                #endregion
                            case "b":
                            case "base":
                                #region Set base address
                                if (!string.IsNullOrEmpty(value))
                                {
                                    if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
                                    {	// Hex format 0x....
                                        if (uint.TryParse(value.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out BaseAddress))
                                            break;
                                    }
                                    else
                                    {
                                        if (uint.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out BaseAddress))
                                            break;
                                    }
                                }
                                exitCode = 1;
                                break;
                                #endregion
                            case "f":
                            case "fill":
                                #region Set empty memory value
                                if (!string.IsNullOrEmpty(value))
                                {
                                    if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
                                    {	// Hex format 0x
                                        if (byte.TryParse(value.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out EmptyValue))
                                            break;
                                    }
                                    else
                                    {	// Decimal format
                                        if (byte.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out EmptyValue))
                                            break;
                                    }
                                }
                                exitCode = 1;
                                break;
                                #endregion
                            case "s":
                            case "scan":
                                #region Set scan file only mode
                                ScanOnly = true;
                                break;
                                #endregion
                            default:
                                #region Unknown option
//.........这里部分代码省略.........
开发者ID:x893,项目名称:Hex2Bin,代码行数:101,代码来源:Program.cs

示例2: _GetSummary

        private DocumentOutput _GetSummary(string root)
        {
            DocumentOutput doc = null;

            /*verificam daca este deja documentul in bd*/
            try {
                doc = this._em.GetDocumentOutput(this._doc.DocumentId, "summ");
                /*ne asiguram ca este scris*/
                using (Stream stream = File.OpenWrite(root + "\\summ.xml")) {
                    byte[] buffer = Encoding.UTF8.GetBytes(doc.Document);
                    stream.Write(buffer, 0, buffer.Length);
                }
            } catch { }

            if (doc != null)
                return doc;

            String input = null;

            using (StreamReader stream = new StreamReader(root + "\\main.txt")) {
                input = stream.ReadToEnd();
            }

            /*cream modulu de sumarizare*/
            /*ISummarizer summarizer = new SimpleSummarizer();
            String output = summarizer.Summarize(input, 40);*/

            String output = null;
            using (StreamReader info = new StreamReader(File.OpenRead(root + "\\info.xml"))) {
                XElement infoDoc = XElement.Parse(info.ReadToEnd());
                output = new Summarisation().ProcessXML(infoDoc);
            }

            if (output == null) return null;

            /*punem in baza de date rezultatul*/

            doc = this._em.AddDocumentOutput(this._doc.DocumentId, "summ",
                DocumentManager.StatusOK, output);

            /*scriem si in fisier*/
            using (Stream stream = File.OpenWrite(root + "\\summ.xml")) {
                byte[] buffer = Encoding.UTF8.GetBytes(output);
                stream.Write(buffer, 0, buffer.Length);
            }

            return doc;
        }
开发者ID:colin-dumitru,项目名称:Proiect-AI-2012---GUI,代码行数:48,代码来源:ModuleWorker.cs


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