本文整理汇总了C#中System.IO.Stream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.Stream.Close方法的具体用法?C# System.IO.Stream.Close怎么用?C# System.IO.Stream.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了System.IO.Stream.Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
/// <summary> Open a RIFF STREAM.
/// </summary>
public virtual int Open(System.IO.Stream stream, int NewMode)
{
int retcode = DDC_SUCCESS;
if (fmode != RFM_UNKNOWN)
{
retcode = Close();
}
if (retcode == DDC_SUCCESS)
{
switch (NewMode)
{
case RFM_WRITE:
try
{
//file = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(Filename, "rw");
file = stream;
try
{
// Write the RIFF header...
// We will have to come back later and patch it!
sbyte[] br = new sbyte[8];
br[0] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 24)) & 0x000000FF);
br[1] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 16)) & 0x000000FF);
br[2] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 8)) & 0x000000FF);
br[3] = (sbyte) (riff_header.ckID & 0x000000FF);
sbyte br4 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 24)) & 0x000000FF);
sbyte br5 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 16)) & 0x000000FF);
sbyte br6 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 8)) & 0x000000FF);
sbyte br7 = (sbyte) (riff_header.ckSize & 0x000000FF);
br[4] = br7;
br[5] = br6;
br[6] = br5;
br[7] = br4;
file.Write(SupportClass.ToByteArray(br), 0, 8);
fmode = RFM_WRITE;
}
catch (System.IO.IOException ioe)
{
file.Close();
fmode = RFM_UNKNOWN;
}
}
catch (System.IO.IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
case RFM_READ:
try
{
file = stream;
//file = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(Filename, "r");
try
{
// Try to read the RIFF header...
sbyte[] br = new sbyte[8];
SupportClass.ReadInput(file, ref br, 0, 8);
fmode = RFM_READ;
riff_header.ckID = ((br[0] << 24) & (int) SupportClass.Identity(0xFF000000)) | ((br[1] << 16) & 0x00FF0000) | ((br[2] << 8) & 0x0000FF00) | (br[3] & 0x000000FF);
riff_header.ckSize = ((br[4] << 24) & (int) SupportClass.Identity(0xFF000000)) | ((br[5] << 16) & 0x00FF0000) | ((br[6] << 8) & 0x0000FF00) | (br[7] & 0x000000FF);
}
catch (System.IO.IOException ioe)
{
file.Close();
fmode = RFM_UNKNOWN;
}
}
catch (System.IO.IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
default:
retcode = DDC_INVALID_CALL;
break;
}
}
return retcode;
}