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


C# FileReader.Read方法代码示例

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


在下文中一共展示了FileReader.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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


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