本文整理汇总了C#中System.IO.FileStream.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.ReadLine方法的具体用法?C# FileStream.ReadLine怎么用?C# FileStream.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileStream
的用法示例。
在下文中一共展示了FileStream.ReadLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestReadLine
public void TestReadLine()
{
var datafile = "../../../data/TestReadLine.txt";
using (FileStream fs = new FileStream(datafile, FileMode.Open))
{
Assert.AreEqual("Start\tLength\tKey", fs.ReadLine());
Assert.AreEqual("55\t1279\tS1,255", fs.ReadLine());
Assert.AreEqual("1334\t1383\tS2,355", fs.ReadLine());
Assert.AreEqual(null, fs.ReadLine());
}
}
示例2: LoadFlie
public static string LoadFlie(string filename)
{
try {
using (var file = new FileStream(filename,FileMode.Open,FileAccess.Read)) {
return file.ReadLine();
}
}
catch (IOException e) {
return "sorry cant open file";
}
}
示例3: ProcessDepthFrameData
// Note: In order to see the full range of depth (including the less reliable far field depth) we are setting maxDepth (ushort.MaxValue) to the extreme potential depth threshold
// If you wish to filter by reliable depth distance, use: depthFrame.DepthMaxReliableDistance
private unsafe void ProcessDepthFrameData(IntPtr depthFrameData, int frameSize, ushort minDepth, ushort maxDepth, DepthSpacePoint p, bool rec, bool left)
{
string file = "";
if (depthFrameSelector == 15 && rec)
{
if (left)
file = String.Format("c:/temp/SLRS/hands/depthDataLeft_{0}_{1}_{2}.txt", gestureWord[gestureNumber], sequenceID, depthFrameIndexL++);
else
file = String.Format("c:/temp/SLRS/hands/depthDataRight_{0}_{1}_{2}.txt", gestureWord[gestureNumber], sequenceID, depthFrameIndexR++);
depthData = new StreamWriter(file, true);
Helper.writePCDHeader(depthData);
}
ushort* frameData = (ushort*)depthFrameData; // depth frame data is a 16 bit value
ushort initDepth = frameData[depthFrameDescription.Width * ((int)p.Y) + ((int)p.X)];
byte initPos = (byte)(initDepth / MapDepthToByte);
int cloudPointCount = 0;
int factor = 80;
int index = 0;
for (int y = -frameSize; y < frameSize; y++)
{
for (int x = -frameSize; x < frameSize; x++)
{
//Select index for smaller frame and get Depth value
int i = (depthFrameDescription.Width * ((int)p.Y + y) + ((int)p.X + x));
ushort depth = frameData[i];
// if this depth is near to the initpoint (handpalm) --> record and adapt depth map for visualization
if (depth < initDepth + factor && depth > initDepth - factor)
{
if (depthFrameSelector == 15 && rec)
{
var point = Helper.depthToPCD(frameSize, p.X + x, p.Y + y, depth);
depthData.WriteLine(String.Format("{0} {1} {2}", point.X, point.Y, point.Z));
cloudPointCount++;
}
depth += (ushort)((depth - initDepth) * 10);
}
else
depth = 0;
this.depthPixels[index++] = (byte)(depth / MapDepthToByte);
//byte greyValue = (byte)(depth >= minDepth && depth <= maxDepth ? (depth / MapDepthToByte) : 0);
//this.depthPixels[index++] = (byte)greyValue;//(255 - greyValue);
}
}
if (depthFrameSelector == 15 && rec)
{
depthData.Flush();
depthData.Close();
FileStream fs = new FileStream(file);
string heigth = cloudPointCount.ToString();
while (!fs.EndOfStream)
{
var line = fs.ReadLine();
if (line.Contains("WIDTH"))
fs.Write(Encoding.ASCII.GetBytes(height), fs.Position+1, height.Lenght);
if (line.Contains("POINTS")) {
fs.Write(Encoding.ASCII.GetBytes(height), fs.Position+1, height.Lenght);
break;
}
}
fs.Flush();
fs.Close();
depthFrameSelector = 0;
}
if (rec) depthFrameSelector++;
}