当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFileStream.BeginWrite方法代码示例

本文整理汇总了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");
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:18,代码来源:IsolatedStorageFileStreamTest.cs

示例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 ();
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:10,代码来源:IsolatedStorageFileStreamTest.cs

示例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");
		}
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:IsolatedStorageFileStreamTest.cs

示例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 ();
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:15,代码来源:IsolatedStorageFileStreamTest.cs

示例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 ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:12,代码来源:IsolatedStorageFileStreamCas.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFileStream.BeginWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。