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


C# FileReader.Close方法代码示例

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


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

示例1: HIM

        public HIM(string file)
        {
            FileReader fr = new FileReader ( file );

            Length = fr.Read<int> ();
            Width = fr.Read<int> ();
            GridCount = fr.Read<int> ();
            GridSize = fr.Read<float> ();

            //fr.BaseStream.Seek (8, System.IO.SeekOrigin.Current);

            Heights = new float[Length, Width];
            MinHeight = 10000000000000000000.0f;
            MaxHeight = 10000.0f;

            for (int y = 0; y < Length; ++y)
            {
                for (int x = 0; x < Width; ++x)
                {
                    Heights [y, x] = fr.Read<float> ();
                    if (Heights [y, x] < MinHeight)
                        MinHeight = Heights [y, x];
                    if (Heights [y, x] > MaxHeight)
                        MaxHeight = Heights [y, x];
                }
            }

            fr.Close ();
        }
开发者ID:osROSE,项目名称:UnityRose,代码行数:29,代码来源:HIM.cs

示例2: Test006_ReadUglyConfig

 public virtual void Test006_ReadUglyConfig()
 {
     FilePath cfg = new FilePath(db.Directory, Constants.CONFIG);
     FileBasedConfig c = new FileBasedConfig(cfg, db.FileSystem);
     string configStr = "  [core];comment\n\tfilemode = yes\n" + "[user]\n" + "  email = A U Thor <[email protected]> # Just an example...\n"
          + " name = \"A  Thor \\\\ \\\"\\t \"\n" + "    defaultCheckInComment = a many line\\n\\\ncomment\\n\\\n"
          + " to test\n";
     Write(cfg, configStr);
     c.Load();
     NUnit.Framework.Assert.AreEqual("yes", c.GetString("core", null, "filemode"));
     NUnit.Framework.Assert.AreEqual("A U Thor <[email protected]>", c.GetString("user"
         , null, "email"));
     NUnit.Framework.Assert.AreEqual("A  Thor \\ \"\t ", c.GetString("user", null, "name"
         ));
     NUnit.Framework.Assert.AreEqual("a many line\ncomment\n to test", c.GetString("user"
         , null, "defaultCheckInComment"));
     c.Save();
     FileReader fr = new FileReader(cfg);
     char[] cbuf = new char[configStr.Length];
     fr.Read(cbuf);
     fr.Close();
     NUnit.Framework.Assert.AreEqual(configStr, new string(cbuf));
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:23,代码来源:T0003_BasicTest.cs

示例3: CardFace

        public CardFace(byte[] bytes,FaceType type)
        {
            faceBytes = bytes;
            faceType = type;

            Stream stream = new MemoryStream(faceBytes);
            FileReader reader = new FileReader(stream);
            reader.ReadBytes(4);//skip Tag 'FACE'
            bgColor = reader.ReadUInt32();
            hasLogo = reader.ReadBoolean();

            byte[] dataBytes;
            byte[] readBytes;
            int len;

            if (hasLogo)
            {
                reader.ReadBytes(16);//skip LogoRect

                logoDepth = reader.ReadUInt32();//LogoDepth

                len = (int)(reader.ReadUInt32());//LogoMatrixBytes
                if (len > 0)
                {
                    logoMatrix = new Matrix(reader.ReadBytes(24));
                }

                len = (int)(reader.ReadUInt32());//LogoColorTransBytes
                if (len > 0)
                {
                    logoColorTrans = new ColorTransform(reader.ReadBytes(32));
                }
            }

            len = (int)(reader.ReadUInt32());//SymbolBytes
            if (len > 0)
            {
                symbols = new SymbolCollection(reader.ReadBytes(len));
            }

            len = (int)(reader.ReadUInt32());//TextBytes
            if (len > 0)
            {
                texts = new TextCollection(reader.ReadBytes(len));
            }

            len = (int)(reader.ReadUInt32());//ThumbnailBytes
            if (len > 0)
            {
                dataBytes=new byte[len];
                readBytes = reader.ReadBytes(len);
                readBytes.CopyTo(dataBytes,0);
                thumbnail = new Thumbnail(dataBytes,ThumbnailType.CardThumbnail);
            }

            stream.Close();
            reader.Close();
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:58,代码来源:CardFace.cs

示例4: Main

    public static int Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Usage : ReadFile <FileName>");
            return 1;
        }

        if (! System.IO.File.Exists(args[0]))
        {
            Console.WriteLine("File " + args[0] + " not found.");
            return 1;
        }

        byte[] buffer = new byte[128];
        FileReader fr = new FileReader();

        if (fr.Open(args[0]))
        {

            // We are assuming that we are reading an ASCII file
            ASCIIEncoding Encoding = new ASCIIEncoding();

            int bytesRead;
            do
            {
                bytesRead = fr.Read(buffer, 0, buffer.Length);
                string content = Encoding.GetString(buffer,0,bytesRead);
                Console.Write("{0}", content);
            }
            while ( bytesRead > 0);

            fr.Close();
            return 0;
        }
        else
        {
            Console.WriteLine("Failed to open requested file");
            return 1;
        }
    }
开发者ID:jamesmaxwell,项目名称:DesignPatternDemo,代码行数:41,代码来源:readfile.cs

示例5: Read

 /// <summary>
 /// Метод для считывания из файла
 /// </summary>
 /// <returns>Возвращает текст из файла</returns>
 public string Read()
 {
     FileReader file = new FileReader(fileName);
      string answer = file.Read();
      minChange = answer.Length;
      file.Close();
      file = null;
      this.changed = false;
      return answer;
 }
开发者ID:dmitriymatus,项目名称:Tasks,代码行数:14,代码来源:Epam_Task9_Library.cs

示例6: Bounce

        /// <summary>
        /// Bounces the specified tags.
        /// </summary>
        /// <param name="tags">The tags.</param>
        /// <param name="files">The files.</param>
        public void Bounce(List<string> tags, List<string> files)
        {
            foreach (var file in files)
            {

                using ( var fileReader = new FileReader(file))
                {
                    _length = fileReader.Length();
                    var output = string.Empty;
                    var trigger = string.Empty;
                    var bounce = false;
                    var close = false;
                    _currentPosition = 0;
                    while (_length > _currentPosition)
                    {
                        var s = fileReader.ReadString(1);
                        _currentPosition++;
                        if (s == ">")
                            close = true;
                        if (s == "<")
                        {

                            trigger = string.Empty;
                            bounce = false;
                            close = false;

                        }
                        if (!close)
                        {
                            trigger = trigger + s;

                        }
                        if (close)
                        {
                            if (s == ">")
                            {
                                trigger = trigger + s;
                                foreach (var tag in tags)
                                {
                                    if (trigger.Contains(tag))
                                        bounce = true;
                                }
                                if (!bounce)
                                {
                                    output = output + trigger;
                                }
                            }
                            else
                            {
                                output = output + s;
                            }

                        }
                    }
                    fileReader.Close();

                    using (var fileWriter = new FileWriter())
                    {
                        fileWriter.WriteFile(output, file);
                    }

                }
            }
        }
开发者ID:romanservices,项目名称:CodeSamples,代码行数:69,代码来源:Shad.cs


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