IsolatedStorageFileStream.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // System.IO.IsolatedStorage.IsolatedStorageFileStream
  2. //
  3. // Sean MacIsaac ([email protected])
  4. //
  5. // (C) 2001 Ximian, Inc.
  6. // (C) 2004 Novell (http://www.novell.com)
  7. using System;
  8. using System.Globalization;
  9. using System.IO;
  10. using System.Reflection;
  11. namespace System.IO.IsolatedStorage {
  12. public class IsolatedStorageFileStream : FileStream
  13. {
  14. private static string CreateIsolatedPath (string path)
  15. {
  16. string dir = IsolatedStorageInfo.CreateAssemblyFilename (Assembly.GetEntryAssembly());
  17. string file = Path.Combine (dir, path);
  18. // Ensure that the file can be created.
  19. FileInfo fi = new FileInfo (file);
  20. if (!fi.Directory.Exists)
  21. fi.Directory.Create ();
  22. return file;
  23. }
  24. public IsolatedStorageFileStream (string path, FileMode mode)
  25. : base(CreateIsolatedPath (path), mode)
  26. {
  27. }
  28. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access)
  29. : base (CreateIsolatedPath (path), mode, access)
  30. {
  31. }
  32. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access, FileShare share)
  33. : base (CreateIsolatedPath (path), mode, access, share)
  34. {
  35. }
  36. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
  37. : base (CreateIsolatedPath (path), mode, access, share, bufferSize)
  38. {
  39. }
  40. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile isf)
  41. : base (CreateIsolatedPath (path), mode, access, share, bufferSize)
  42. {
  43. }
  44. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)
  45. : base (CreateIsolatedPath (path), mode, access, share)
  46. {
  47. }
  48. public IsolatedStorageFileStream (string path, FileMode mode, FileAccess access, IsolatedStorageFile isf)
  49. : base (CreateIsolatedPath (path), mode, access)
  50. {
  51. }
  52. public IsolatedStorageFileStream (string path, FileMode mode, IsolatedStorageFile isf)
  53. : base (CreateIsolatedPath (path), mode)
  54. {
  55. }
  56. public override bool CanRead {
  57. get {return base.CanRead;}
  58. }
  59. public override bool CanSeek {
  60. get {return base.CanSeek;}
  61. }
  62. public override bool CanWrite {
  63. get {return base.CanWrite;}
  64. }
  65. public override IntPtr Handle {
  66. get {
  67. throw new IsolatedStorageException (
  68. Locale.GetText ("Information is restricted"));
  69. }
  70. }
  71. public override bool IsAsync {
  72. get {return base.IsAsync;}
  73. }
  74. public override long Length {
  75. get {return base.Length;}
  76. }
  77. public override long Position {
  78. get {return base.Position;}
  79. set {base.Position = value;}
  80. }
  81. public override IAsyncResult BeginRead (byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, object stateObject)
  82. {
  83. return base.BeginRead (buffer, offset, numBytes, userCallback, stateObject);
  84. }
  85. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, object stateObject)
  86. {
  87. return base.BeginWrite (buffer, offset, numBytes, userCallback, stateObject);
  88. }
  89. public override void Close ()
  90. {
  91. base.Close ();
  92. }
  93. public override int EndRead (IAsyncResult asyncResult)
  94. {
  95. return base.EndRead (asyncResult);
  96. }
  97. public override void EndWrite (IAsyncResult asyncResult)
  98. {
  99. base.EndWrite (asyncResult);
  100. }
  101. public override void Flush ()
  102. {
  103. base.Flush ();
  104. }
  105. public override int Read (byte[] buffer, int offset, int count)
  106. {
  107. return base.Read (buffer, offset, count);
  108. }
  109. public override int ReadByte ()
  110. {
  111. return base.ReadByte ();
  112. }
  113. public override long Seek (long offset, SeekOrigin origin)
  114. {
  115. return base.Seek (offset, origin);
  116. }
  117. public override void SetLength (long value)
  118. {
  119. base.SetLength (value);
  120. }
  121. public override void Write (byte[] buffer, int offset, int count)
  122. {
  123. base.Write (buffer, offset, count);
  124. }
  125. public override void WriteByte (byte value)
  126. {
  127. base.WriteByte (value);
  128. }
  129. protected override void Dispose (bool disposing)
  130. {
  131. base.Dispose (disposing);
  132. }
  133. }
  134. }