本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.BeginWrite方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.BeginWrite方法的具体用法?C# IsolatedStorageFileStream.BeginWrite怎么用?C# IsolatedStorageFileStream.BeginWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.BeginWrite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOnly
public void ReadOnly ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
try {
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("read-only", FileMode.Create, FileAccess.Write, isf)) {
fs.WriteByte (0);
}
// now we open it read-only
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("read-only", FileMode.Open, FileAccess.Read, isf)) {
Assert.Throws (delegate { fs.WriteByte (0); }, typeof (NotSupportedException), "WriteByte");
Assert.Throws (delegate { fs.Write (new byte [0], 0, 0); }, typeof (NotSupportedException), "Write");
Assert.Throws (delegate { fs.BeginWrite (new byte [0], 0, 0, null, null); }, typeof (NotSupportedException), "BeginWrite");
}
}
finally {
isf.DeleteFile ("read-only");
}
}
示例2: AsyncEndWrite_Disposed
public void AsyncEndWrite_Disposed ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte [] data = new byte [2];
KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> kvp = new KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> (isf, fs);
IAsyncResult result = fs.BeginWrite (data, 0, 2, new AsyncCallback (EndWriteDisposed), kvp);
result.AsyncWaitHandle.WaitOne ();
}
}
示例3: AsyncWrite
public void AsyncWrite ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte[] data = new byte [2];
IAsyncResult result = fs.BeginWrite (data, 0, 2, new AsyncCallback (EndWrite), fs);
result.AsyncWaitHandle.WaitOne ();
isf.Remove (); // this removed everything
Assert.Throws (delegate { fs.BeginWrite (data, 0, 2, new AsyncCallback (EndWrite), fs); }, typeof (IsolatedStorageException), "Remove/Write"); // Fails in Silverlight 3
isf.Dispose ();
Assert.Throws (delegate { fs.BeginWrite (data, 0, 2, new AsyncCallback (EndWrite), fs); }, typeof (ObjectDisposedException), "Dispose/Write");
}
isf = IsolatedStorageFile.GetUserStoreForApplication ();
Assert.AreEqual (0, isf.GetFileNames ().Length, "Empty");
}
示例4: AsyncEndWrite_Removed
public void AsyncEndWrite_Removed ()
{
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
isf.Remove ();
isf = IsolatedStorageFile.GetUserStoreForApplication ();
Assert.AreEqual (0, isf.GetFileNames ().Length, "pre-check");
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
byte [] data = new byte [2];
KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> kvp = new KeyValuePair<IsolatedStorageFile, IsolatedStorageFileStream> (isf, fs);
IAsyncResult result = fs.BeginWrite (data, 0, 2, new AsyncCallback (EndWriteRemoved), kvp);
result.AsyncWaitHandle.WaitOne ();
}
}
示例5: AsyncWrite
public void AsyncWrite ()
{
IsolatedStorageFileStream isfs = new IsolatedStorageFileStream ("cas-AsyncWrite", FileMode.Create);
message = "AsyncWrite";
reset.Reset ();
IAsyncResult r = isfs.BeginWrite (new byte[0], 0, 0, new AsyncCallback (WriteCallback), isfs);
Assert.IsNotNull (r, "IAsyncResult");
if (!reset.WaitOne (timeout, true))
Assert.Ignore ("Timeout");
Assert.IsNull (message, message);
isfs.Close ();
}