本文整理汇总了C#中Mono.Unix.StdioFileStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# StdioFileStream.Close方法的具体用法?C# StdioFileStream.Close怎么用?C# StdioFileStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Unix.StdioFileStream
的用法示例。
在下文中一共展示了StdioFileStream.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CtorFileNotFoundException1
public void CtorFileNotFoundException1 ()
{
string path = TempFolder + DSC + "thisfileshouldnotexists.test";
DeleteFile (path);
StdioFileStream stream = null;
try {
stream = new StdioFileStream (path, FileMode.Open);
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
示例2: TestCtr
public void TestCtr ()
{
string path = TempFolder + DSC + "testfilestream.tmp.1";
DeleteFile (path);
StdioFileStream stream = null;
try {
stream = new StdioFileStream (path, FileMode.Create);
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
示例3: CtorAccess1Read2Read
public void CtorAccess1Read2Read ()
{
StdioFileStream fs = null;
StdioFileStream fs2 = null;
try {
if (!File.Exists ("temp")) {
TextWriter tw = File.CreateText ("temp");
tw.Write ("FOO");
tw.Close ();
}
fs = new StdioFileStream ("temp", FileMode.Open, FileAccess.Read);
fs2 = new StdioFileStream ("temp", FileMode.Open, FileAccess.Read);
} finally {
if (fs != null)
fs.Close ();
if (fs2 != null)
fs2.Close ();
if (File.Exists ("temp"))
File.Delete ("temp");
}
}
示例4: ReadBytePastEndOfStream
public void ReadBytePastEndOfStream ()
{
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
DeleteFile (path);
using (StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Read)) {
stream.Seek (0, SeekOrigin.End);
Assert.AreEqual (-1, stream.ReadByte (), "ReadByte");
stream.Close ();
}
}
示例5: Seek_Disposed
public void Seek_Disposed ()
{
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
DeleteFile (path);
StdioFileStream stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
stream.Close ();
stream.Seek (0, SeekOrigin.Begin);
}
示例6: CtorArgumentException1
public void CtorArgumentException1 ()
{
StdioFileStream stream;
stream = new StdioFileStream ("", FileMode.Create);
stream.Close ();
}
示例7: TestReadByteVerifyAccessMode
public void TestReadByteVerifyAccessMode ()
{
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
DeleteFile (path);
StdioFileStream stream = null;
try {
stream = new StdioFileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
int readByte = stream.ReadByte ();
} finally {
if (stream != null)
stream.Close();
DeleteFile (path);
}
}
示例8: TestClose
public void TestClose ()
{
#if FALSE
string path = TempFolder + Path.DirectorySeparatorChar + "TestClose";
DeleteFile (path);
StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
stream.Write (new byte [] {1, 2, 3, 4}, 0, 4);
stream.ReadByte ();
stream.Close ();
try {
stream.ReadByte ();
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#01");
}
try {
stream.WriteByte (64);
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#02");
}
try {
stream.Flush ();
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#03");
}
try {
long l = stream.Length;
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#04");
}
try {
long l = stream.Position;
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#05");
}
try {
FilePosition fp = stream.FilePosition;
fp.Dispose ();
Assert.Fail ();
} catch (Exception e) {
Assert.AreEqual (typeof (ObjectDisposedException), e.GetType (), "test#05");
}
Assert.AreEqual (false, stream.CanRead, "test#06");
Assert.AreEqual (false, stream.CanSeek, "test#07");
Assert.AreEqual (false, stream.CanWrite, "test#08");
DeleteFile (path);
#endif
}
示例9: CtorDirectoryNotFoundException
public void CtorDirectoryNotFoundException ()
{
string path = TempFolder + DSC + "thisDirectoryShouldNotExists";
if (Directory.Exists (path))
Directory.Delete (path, true);
StdioFileStream stream = null;
try {
stream = new StdioFileStream (path + DSC + "eitherthisfile.test", FileMode.CreateNew);
} finally {
if (stream != null)
stream.Close ();
if (Directory.Exists (path))
Directory.Delete (path, true);
}
}
示例10: CtorArgumentOutOfRangeException2
public void CtorArgumentOutOfRangeException2 ()
{
StdioFileStream stream = null;
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
DeleteFile (path);
try {
stream = new StdioFileStream ("test.test.test", FileMode.Append | FileMode.Open);
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
示例11: CtorIOException1
public void CtorIOException1 ()
{
string path = TempFolder + DSC + "thisfileshouldexists.test";
StdioFileStream stream = null;
DeleteFile (path);
try {
stream = new StdioFileStream (path, FileMode.CreateNew);
stream.Close ();
stream = null;
stream = new StdioFileStream (path, FileMode.CreateNew);
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
示例12: SetLengthWithClosedBaseStream
public void SetLengthWithClosedBaseStream ()
{
StdioFileStream fs = new StdioFileStream ("temp", FileMode.Create);
BufferedStream bs = new BufferedStream (fs);
fs.Close ();
bs.SetLength (1000);
}
示例13: 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);
}
}
示例14: Seek
public void Seek ()
{
string path = TempFolder + DSC + "FST.Seek.Test";
DeleteFile (path);
StdioFileStream stream = new StdioFileStream (path, FileMode.CreateNew, FileAccess.ReadWrite);
StdioFileStream stream2 = new StdioFileStream (path, FileMode.Open, FileAccess.ReadWrite);
stream.Write (new byte [] {1, 2, 3, 4, 5, 6, 7, 8, 10}, 0, 9);
Assert.AreEqual (5, stream2.Seek (5, SeekOrigin.Begin), "test#01");
Assert.AreEqual (-1, stream2.ReadByte (), "test#02");
Assert.AreEqual (2, stream2.Seek (-3, SeekOrigin.Current), "test#03");
Assert.AreEqual (-1, stream2.ReadByte (), "test#04");
Assert.AreEqual (12, stream.Seek (3, SeekOrigin.Current), "test#05");
Assert.AreEqual (-1, stream.ReadByte (), "test#06");
Assert.AreEqual (5, stream.Seek (-7, SeekOrigin.Current), "test#07");
Assert.AreEqual (6, stream.ReadByte (), "test#08");
Assert.AreEqual (5, stream2.Seek (5, SeekOrigin.Begin), "test#09");
Assert.AreEqual (6, stream2.ReadByte (), "test#10");
stream.Close ();
stream2.Close ();
DeleteFile (path);
}
示例15: CtorArgumentException3
public void CtorArgumentException3 ()
{
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
StdioFileStream stream = null;
DeleteFile (path);
try {
stream = new StdioFileStream (".test.test.test.2", FileMode.Truncate, FileAccess.Read);
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}