本文整理汇总了C#中FileStream.EndWrite方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.EndWrite方法的具体用法?C# FileStream.EndWrite怎么用?C# FileStream.EndWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream.EndWrite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runTest
//.........这里部分代码省略.........
{
fs2.Write(new Byte[]{1}, 0, 1);
iCountErrors++;
printerr( "Error_2000m! Expected exception not thrown");
}
catch (ObjectDisposedException iexc)
{
printinfo( "Info_2000n! Caught expected exception, iexc=="+iexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_2000o! Incorrect exception thrown, exc=="+exc.ToString());
}
iCountTestcases++;
try
{
fs2.Read(new Byte[1], 0, 1);
iCountErrors++;
printerr( "Error_2000p! Expected exception not thrown");
}
catch (ObjectDisposedException iexc)
{
printinfo( "Info_2000q! Caught expected exception, iexc=="+iexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_2000r! Incorrect exception thrown, exc=="+exc.ToString());
}
iCountTestcases++;
try
{
fs2.EndWrite(fs2.BeginWrite(new Byte[]{1}, 0, 1, null, null));
iCountErrors++;
printerr( "Error_2000s! Expected exception not thrown");
}
catch (ObjectDisposedException iexc)
{
printinfo( "Info_2000t! Caught expected exception, iexc=="+iexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr("Error_2000u! Incorrect exception thrown, exc=="+exc.ToString());
}
iCountTestcases++;
try
{
fs2.EndRead(fs2.BeginRead(new Byte[1], 0, 1, null, null));
iCountErrors++;
printerr("Error_2000v! Expected exception not thrown");
}
catch (ObjectDisposedException iexc)
{
printinfo( "Info_2000w! Caught expected exception, iexc=="+iexc.Message);
}
catch( Exception exc)
{
iCountErrors++;
printerr( "Error_2000x! Incorrect exception thrown, exc=="+exc.ToString());
}
iCountTestcases++;
try
{
fs2.Flush();
示例2: runTest
//.........这里部分代码省略.........
printerr( "Error_t958g! Incorrect exception thrown, exc=="+exc.ToString());
}
fs2.Close();
}
strLoc = "Loc_399il";
for(int iLoop = 0 ; iLoop < iArrLargeValues.Length ; iLoop++)
{
fs2 = new FileStream(fileName, FileMode.Open);
iCountTestcases++;
bArr = new Byte[]{0,1};
try
{
fs2.BeginRead(bArr, 0, iArrLargeValues[iLoop], null, null);
iCountErrors++;
printerr( "Error_5520j! Expected exception not thrown");
}
catch (ArgumentException aexc)
{
printinfo( "Info_88tum! Caught expected exception, aexc=="+aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_2090t! Incorrect exception thrown, exc=="+exc.ToString());
}
fs2.Close();
}
strLoc = "Loc_388hj";
fs2 = new FileStream(fileName, FileMode.Open);
ascb = new AsyncCallback(this.CallBackMethod);
bCallBackCalled = false;
bArr = new Byte[]{0,1,2,3};
iar = fs2.BeginWrite(bArr, 0, 4, ascb, 5);
fs2.EndWrite(iar);
Thread.Sleep(1000);
iCountTestcases++;
if(!bCallBackCalled)
{
iCountErrors++;
printerr( "Error_489xh! CallBackmethod not called");
}
iCountTestcases++;
if(!iar.IsCompleted)
{
iCountErrors++;
printerr( "Error_29ycy! Completed not set correctly");
}
iCountTestcases++;
if(!iar.CompletedSynchronously)
{
iCountErrors++;
printerr( "Error_8998c! Not done async");
}
iCountTestcases++;
if((Int32)iar.AsyncState != 5)
{
iCountErrors++;
printerr( "Error_20hvb! Incorrect AsyncState");
}
fs2.Position = 0;
bResultArr = new Byte[8];
iar = fs2.BeginRead(bResultArr, 2, 3, ascb, 5);
fs2.EndRead(iar);
for(int i = 2 ; i < 5 ; i++)
{
iCountTestcases++;
示例3: runTest
//.........这里部分代码省略.........
{
iCountErrors++;
printerr( "Error_47f7v_"+i+"! Expected=="+i+" , got=="+b);
}
i++;
}
fs2.Close();
fs3.Close();
strLoc = "Loc_487ty";
iCountTestcases++;
try
{
fs2 = new FileStream(new IntPtr(2), (FileAccess)(-2), true, 2000);
iCountErrors++;
printerr( "Error_f489y! Expected exception not thrown");
}
catch (ArgumentException aexc)
{
printinfo( "Info_4t98c! Caught expected exception, aexc=="+aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_4398g! Incorrect exception thrown, exc=="+exc.ToString());
}
strLoc = "Loc_399f9";
fs2 = new FileStream(filName, FileMode.Create);
fs3 = new FileStream(fs2.Handle, FileAccess.Read, true, 4000);
fs3.Close();
iCountTestcases++;
try
{
fs2.Write(new Byte[]{1}, 0, 1);
fs2.Flush();
iCountErrors++;
printerr( "Error_3f8vc! Expected exception not thrown");
}
catch (IOException iexc)
{
printinfo( "Info_398fc! Caught expected exception, iexc=="+iexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_98gyg! Incorrect exception thrown, exc=="+exc.ToString());
}
fs2.Close();
strLoc = "Loc_99f99";
fs2 = new FileStream(filName, FileMode.Create);
fs3 = new FileStream(fs2.Handle, FileAccess.Read, false, 16000);
fs3.Close();
try
{
fs2.Write(new Byte[]{1}, 0, 1);
fs2.Flush();
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_3989c! Unexpected exception, exc=="+exc.ToString());
}
fs2.Close();
strLoc = "Loc_498vy";
fs2 = new FileStream("Bug.txt", FileMode.Create);
try
{
fs3 = new FileStream(fs2.Handle, FileAccess.ReadWrite, false, Int32.MaxValue/100);
Byte[] bArr = new Byte[100*10];
for(int ii = 0 ; ii < bArr.Length ;ii++)
bArr[i] = (Byte)ii;
IAsyncResult iar = fs3.BeginWrite(bArr, 0, bArr.Length, null, null);
fs3.EndWrite(iar);
fs3.Close();
fs2.Close();
}
catch( Exception e )
{
Console.WriteLine("Unexpected exception occured... " + e.ToString() );
}
File.Delete("Bug.txt");
if(File.Exists(filName))
File.Delete(filName);
}
catch (Exception exc_general )
{
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例4: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
String strLoc = "Loc_000oo";
String strValue = String.Empty;
int iCountErrors = 0;
int iCountTestcases = 0;
try
{
String filName = s_strTFAbbrev+"TestFile";
Stream fs2;
IAsyncResult iar;
Byte[] bArr;
if(File.Exists(filName))
File.Delete(filName);
strLoc = "Loc_100aa";
fs2 = new FileStream(filName, FileMode.Create);
iCountTestcases++;
try
{
fs2.EndWrite(null);
iCountErrors++;
printerr( "Error_100bb! Expected exception not thrown");
}
catch (ArgumentNullException aexc)
{
printinfo( "Info_100cc! Caught expected exception, aexc=="+aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_100dd Incorrect exception thrown, exc=="+exc.ToString());
}
fs2.Close();
strLoc = "Loc_200aa";
fs2 = new FileStream(filName, FileMode.Create);
iar = fs2.BeginRead(new Byte[0], 0, 0, null, null);
iCountTestcases++;
try
{
fs2.EndWrite(iar);
iCountErrors++;
printerr( "Error_200bb! Expected exception not thrown");
}
catch (ArgumentException aexc)
{
printinfo ("Info_200cc! Caught expected exception, aexc=="+aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_200dd! Incorrect exception thrown, exc=="+exc.ToString());
}
fs2.Close();
strLoc = "Loc_300aa";
fs2 = new FileStream(filName, FileMode.Create);
bArr = new Byte[1024*1000];
for(int i = 0 ; i < bArr.Length ; i++)
bArr[i] = (Byte)i;
iar = fs2.BeginWrite(bArr, 0, bArr.Length, null, null);
fs2.EndWrite(iar);
iCountTestcases++;
if(!iar.IsCompleted)
{
iCountErrors++;
printerr( " Error_300dd! Operation should be complete");
}
iCountTestcases++;
iCountTestcases++;
if(fs2.Length != bArr.Length)
{
iCountErrors++;
printerr( "Error_300bb! Expected=="+bArr.Length+", Return=="+fs2.Length);
}
fs2.Close();
strLoc = "Loc_400aa";
fs2 = new FileStream(filName, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 100, true);
bArr = new Byte[1000*1024];
for(int i = 0 ; i < bArr.Length ; i++)
bArr[i] = (Byte)i;
iar = fs2.BeginWrite(bArr, 0, bArr.Length, null, null);
fs2.EndWrite(iar);
iCountTestcases++;
if(!iar.IsCompleted)
{
iCountErrors++;
printerr( "Error_400bb! Operation should be complete");
}
iCountTestcases++;
iCountTestcases++;
if(fs2.Length != bArr.Length)
{
iCountErrors++;
printerr( "Error_400dd! Expected=="+bArr.Length+", Return=="+fs2.Length);
}
fs2.Close();
if(File.Exists(filName))
File.Delete(filName);
}
catch (Exception exc_general )
//.........这里部分代码省略.........