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


C# FileStream.ReadLine方法代码示例

本文整理汇总了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());
      }
    }
开发者ID:shengqh,项目名称:RCPA.Test,代码行数:12,代码来源:TestFileExtension.cs

示例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";
     }
 }
开发者ID:d7p,项目名称:Miscellaneous,代码行数:11,代码来源:Main.cs

示例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++;
        }
开发者ID:madingo87,项目名称:netica,代码行数:78,代码来源:KinectApp.xaml.cs


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