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


C# BufferedStream.Seek方法代码示例

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


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

示例1: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     try
     {
         BufferedStream bs2;
         MemoryStream memstr2;
         if(File.Exists("Co5604Test.tmp"))
             File.Delete("Co5604Test.tmp");
         strLoc = "Loc_857vi";
         memstr2 = new MemoryStream();
         bs2 = new BufferedStream(memstr2);
         bs2.Write(new Byte[]{65, 66}, 0, 2);
         bs2.Close();
         iCountTestcases++;
         try 
         {
             bs2.Flush();
             iCountErrors++;
             printerr("Error_2yc94! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_298uv! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_9t85y! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_09uf4";
         iCountTestcases++;
         try 
         {
             bs2.Write(new Byte[]{1,2,3}, 0, 3);
             iCountErrors++;
             printerr( "Error_129vc! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_27b99! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "ERror_0901v! Incorrect exception thrown, exc=="+exc.ToString());
         } 
         strLoc = "Loc_2099x";
         iCountTestcases++;
         try 
         {
             bs2.Read(new Byte[3], 0, 3);
             iCountErrors++;
             printerr( "Error_209cx! Expectede exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_t7587! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_20g8j! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_01990";
         iCountTestcases++;
         try 
         {
             bs2.Seek(54, SeekOrigin.Current);
             iCountErrors++;
             printerr( "Error_0190j! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_g6798! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_2998y! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_0939s";
         iCountTestcases++;
         try 
         {
             bs2.SetLength(100);
             iCountErrors++;
             printerr( "Error_209gb! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo( "Info_989gh! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_0190x! Incorrect exception thrown, exc=="+exc.Message);
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5604close.cs

示例2: Teleport

 public static void Teleport(string address) 
 {
     TcpClient tcpClient = new TcpClient();
     IPEndPoint epSend = null;
     IPAddress sendAddress = IPAddress.Parse(address);			
     epSend = new IPEndPoint(sendAddress, iPortNumber);
     tcpClient.Connect(epSend);
     Stream stream = tcpClient.GetStream();
     BufferedStream bs = new BufferedStream( stream);
     bs.Write(new Byte[]{0,1,2}, 0, 3);
     try
     {
         bs.Seek( 1, SeekOrigin.Begin);
         iCountErrors++;
         Console.WriteLine( "Error_8888! Expecte exception not occured ");
     } 
     catch( NotSupportedException iexc) 
     {
         Console.WriteLine("INFO: Expected exception occured, iexc == " + iexc.Message );
     } 
     catch( Exception )
     {
         iCountErrors++;
         Console.WriteLine( "Error_434234! Able to set the Network stream position ");
     } 
 }
开发者ID:ArildF,项目名称:masters,代码行数:26,代码来源:co5614seek_i64_so.cs

示例3: SeekOnUnseekableStream_Throws_NotSupportedException

 public static void SeekOnUnseekableStream_Throws_NotSupportedException()
 {
     using (WrappedMemoryStream underlying = new WrappedMemoryStream(true, true, false))
     using (BufferedStream stream = new BufferedStream(underlying))
     {
         Assert.Throws<NotSupportedException>(() => stream.Seek(0, new SeekOrigin()));
     }
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:8,代码来源:BufferedStream.InvalidParameters.cs

示例4: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     try
     {
         BufferedStream bs2;
         MemoryStream memstr2;
         FileStream fs2;
         Int64 pos;
         if(File.Exists("Co5614Test.tmp"))
             File.Delete("Co5614Test.tmp");
         strLoc = "Loc_95vy8";
         memstr2 = new MemoryStream();
         bs2 = new BufferedStream(memstr2);
         bs2.Write(new Byte[]{1,2,3,4}, 0, 4);
         bs2.Flush();
         iCountTestcases++;
         try 
         {
             bs2.Seek(-2, SeekOrigin.Begin);
             iCountErrors++;
             printerr( "Error_98yvc! Expected exception not thrown");
         } 
         catch (IOException aexc) 
         {
             printinfo("Info_20u90! Caught expected exception, exc=="+aexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_f3099! Incorrect exception thrown, exc=="+exc.ToString());
         }
         iCountTestcases++;
         if(bs2.Position != 4) 
         {
             iCountErrors++;
             printerr( "Error_298hx! Position set=="+bs2.Position);
         }
         bs2.Position = 1;
         iCountTestcases++;
         try 
         {
             bs2.Seek(-2, SeekOrigin.Begin);
             iCountErrors++;
             printerr( "Error_0190cj! Expected exception not thrown");
         } 
         catch (IOException aexc) 
         {
             printinfo("Info_98yg9! Caught expected exception, exc=="+aexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_98t8b! Incorrect exception thrown, exc=="+exc.ToString());
         }
         iCountTestcases++;
         if(bs2.Position != 1) 
         {
             iCountErrors++;
             printerr( "Error_29887! Position set=="+bs2.Position);
         }
         bs2.Close();
         strLoc = "Loc_98yvh";
         fs2 = new FileStream("Co5614Test.tmp", FileMode.Create);
         bs2 = new BufferedStream(fs2);
         bs2.Write(new Byte[]{1,2,3,4},0,4);
         bs2.Flush();
         iCountTestcases++;
         try 
         {
             bs2.Seek(-2, SeekOrigin.Begin);
             iCountErrors++;
             printerr( "Error_019uc! Expected exception not thrown");
         } 
         catch (IOException aexc) 
         {
             printinfo("Info_78y7g! Caught expected exception, exc=="+aexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_099gn! Incorrect exception thrown, exc=="+exc.ToString());
         } 
         iCountTestcases++;
         if(bs2.Position != 4) 
         {
             iCountErrors++;
             printerr( "Error_9t8yb! Position set=="+bs2.Position);
         }
         bs2.Position = 1;
         iCountTestcases++;
         try 
         {
             bs2.Seek(-2, SeekOrigin.Begin);
             iCountErrors++;
             printerr( "Error_98ycn! Expected exception not thrown");
         } 
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5614seek_i64_so.cs


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