本文整理汇总了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 ();
}
示例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));
}
示例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;
}
}