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


C# StdioFileStream.Read方法代码示例

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


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

示例1: Read_CountOverflow

		public void Read_CountOverflow ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Read (new byte[0], 1, Int32.MaxValue);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:9,代码来源:StdioFileStreamTest.cs

示例2: Read_OffsetNegative

		public void Read_OffsetNegative ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
				stream.Read (new byte[0], -1, 1);
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:9,代码来源:StdioFileStreamTest.cs

示例3: TestReadVerifyAccessMode

		public void TestReadVerifyAccessMode ()
		{
			string path = TempFolder + Path.DirectorySeparatorChar + "temp";
			DeleteFile (path);

			StdioFileStream stream = null;
			byte[] buffer = new byte [100];

			try {
				stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
				stream.Read (buffer, 0, buffer.Length);
			} finally {
				if (stream != null)
					stream.Close ();
			}
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:16,代码来源:StdioFileStreamTest.cs

示例4: Flush

		public void Flush ()
		{
#if XXX
		    // This test depends too much on the internal implementation of stdio's FILE
		    
			string path = TempFolder + DSC + "StdioFileStreamTest.Flush";
			StdioFileStream stream = null;
			StdioFileStream stream2 = null;

			DeleteFile (path);

			try {
				stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
				stream2 = new StdioFileStream (path, FileMode.Open, FileAccess.ReadWrite);

				stream.Write (new byte [] {1, 2, 3, 4, 5}, 0, 5);

				byte [] bytes = new byte [5];
				stream2.Read (bytes, 0, 5);

				Assert.AreEqual (0, bytes [0], "test#01");
				Assert.AreEqual (0, bytes [1], "test#02");
				Assert.AreEqual (0, bytes [2], "test#03");
				Assert.AreEqual (0, bytes [3], "test#04");

				stream.Flush ();
				stream2.Read (bytes, 0, 5);			
				Assert.AreEqual (1, bytes [0], "test#05");
				Assert.AreEqual (2, bytes [1], "test#06");
				Assert.AreEqual (3, bytes [2], "test#07");
				Assert.AreEqual (4, bytes [3], "test#08");
			} finally {
				if (stream != null)
					stream.Close ();
				if (stream2 != null)
					stream2.Close ();

				Console.WriteLine ("P: " + path);
				//DeleteFile (path);
			}
#endif
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:42,代码来源:StdioFileStreamTest.cs

示例5: Write

		public void Write ()
		{
			string path = TempFolder + DSC + "StdioFileStreamTest.Write";

			DeleteFile (path);

			StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);

			byte[] outbytes = new byte [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
			byte[] bytes = new byte [15];

			// Check that the data is flushed when we overflow the buffer
			// with a large amount of data
			stream.Write (outbytes, 0, 5);
			stream.Write (outbytes, 5, 10);
			stream.Seek (0, SeekOrigin.Begin);

			stream.Read (bytes, 0, 15);
			for (int i = 0; i < 15; ++i)
				Assert.AreEqual (i + 1, bytes [i]);

			// Check that the data is flushed when we overflow the buffer
			// with a small amount of data
			stream.Write (outbytes, 0, 7);
			stream.Write (outbytes, 7, 7);
			stream.Write (outbytes, 14, 1);

			stream.Seek (15, SeekOrigin.Begin);
			Array.Clear (bytes, 0, bytes.Length);
			stream.Read (bytes, 0, 15);
			for (int i = 0; i < 15; ++i)
				Assert.AreEqual (i + 1, bytes [i]);
			stream.Close ();
		}
开发者ID:sushihangover,项目名称:playscript,代码行数:34,代码来源:StdioFileStreamTest.cs

示例6: Flush

		public void Flush ()
		{
			string path = TempFolder + DSC + "StdioFileStreamTest.Flush";
			StdioFileStream stream = null;
			StdioFileStream stream2 = null;

			DeleteFile (path);

			try {
				stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
				stream2 = new StdioFileStream (path, FileMode.Open, FileAccess.ReadWrite);

				stream.Write (new byte [] {1, 2, 3, 4, 5}, 0, 5);

				byte [] bytes = new byte [5];
				stream2.Read (bytes, 0, 5);

				Assert.AreEqual (0, bytes [0], "test#01");
				Assert.AreEqual (0, bytes [1], "test#02");
				Assert.AreEqual (0, bytes [2], "test#03");
				Assert.AreEqual (0, bytes [3], "test#04");

				stream.Flush ();
				stream2.Read (bytes, 0, 5);			
				Assert.AreEqual (1, bytes [0], "test#05");
				Assert.AreEqual (2, bytes [1], "test#06");
				Assert.AreEqual (3, bytes [2], "test#07");
				Assert.AreEqual (4, bytes [3], "test#08");
			} finally {
				if (stream != null)
					stream.Close ();
				if (stream2 != null)
					stream2.Close ();

				DeleteFile (path);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:37,代码来源:StdioFileStreamTest.cs


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