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


C# IsolatedStorageFileStream.WriteByte方法代码示例

本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.WriteByte方法的具体用法?C# IsolatedStorageFileStream.WriteByte怎么用?C# IsolatedStorageFileStream.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IsolatedStorage.IsolatedStorageFileStream的用法示例。


在下文中一共展示了IsolatedStorageFileStream.WriteByte方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDirectory_DirectoryWithSameNameExists

		public void CreateDirectory_DirectoryWithSameNameExists ()
		{
			string dir = "new-dir";
			string file = Path.Combine (dir, "new-file");
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			try {
				isf.CreateDirectory (dir);
				using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (file, FileMode.OpenOrCreate, isf)) {
					isfs.WriteByte (0);
				}
				string pattern = Path.Combine (dir, "*");
				Assert.AreEqual (1, isf.GetFileNames (file).Length, "file exists");

				// create again directory
				isf.CreateDirectory (dir);
				Assert.AreEqual (1, isf.GetFileNames (file).Length, "file still exists");
			}
			finally {
				isf.DeleteFile (file);
				isf.DeleteDirectory (dir);
			}
		}
开发者ID:nkuln,项目名称:mono,代码行数:22,代码来源:IsolatedStorageFileTest.cs

示例2: download

        private void download(String name)
        {
            GlobalVar.client.Send("1" + "\n");
            GlobalVar.client.Send(name + "\n");
            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            // Create a new folder and call it "MyFolder".
            myStore.CreateDirectory("MyFolder");
            string temp = GlobalVar.client.Receive();
            // Specify the file path and options.
            using (var isoFileStream = new IsolatedStorageFileStream("MyFolder\\" + name, FileMode.OpenOrCreate, myStore))
            {
                //Write the data
                using (var isoFileWriter = new StreamWriter(isoFileStream))
                {
                    bool done = false;
                    while (temp.CompareTo("null") != 0)
                    {
                        string[] all = temp.Split('\n');
                        for (int i = 0; i < all.Length; i++)
                        {
                            if (all[i].CompareTo("null") != 0)
                            {
                                if (all[i].CompareTo("") != 0)
                                    isoFileStream.WriteByte(Convert.ToByte(all[i]));
                            }
                            else
                            {
                                done = true;
                                break;
                            }
                        }
                        if (done) break;

                        temp = GlobalVar.client.Receive();
                    }
                }
            }
        }
开发者ID:sauravmahajan,项目名称:CDN-WindowsApp,代码行数:39,代码来源:explorer.xaml.cs

示例3: resume

        public Boolean resume()
        {

            if (GlobalVar.doTransfer)
            {

                GlobalVar.client.Send("3" + "\n");
                GlobalVar.client.Send(name + "\n");
                IsolatedStorageFile myStore2 = IsolatedStorageFile.GetUserStoreForApplication();

                // Create a new folder and call it "MyFolder".
                myStore2.CreateDirectory("MyFolder");
                using (var isoFileStream2 = new IsolatedStorageFileStream("MyFolder\\" + name, FileMode.OpenOrCreate, myStore2))
                {
                    String tosendint = isoFileStream2.Length.ToString();
                    GlobalVar.client.Send(tosendint + "\n");
                    Thread.SpinWait(1000);
                    Thread.Sleep(1000);
                    isoFileStream2.Close();
                }
                IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

                // Create a new folder and call it "MyFolder".
                myStore.CreateDirectory("MyFolder");
                using (var isoFileStream = new IsolatedStorageFileStream("MyFolder\\" + name, FileMode.OpenOrCreate, myStore))
                {

                    try
                    {
                        string temp = "";
                        String inp = GlobalVar.client.Receive();

                        while (!(inp.Contains("null1") || inp.Contains("null")))
                        {
                            temp = temp + inp;
                            inp = GlobalVar.client.Receive(); ;
                        }
                        temp = temp + inp;

                        //string temp = GlobalVar.client.Receive();
                        isoFileStream.Position = isoFileStream.Length;
                        // Specify the file path and options.

                        //Write the data
                        using (var isoFileWriter = new StreamWriter(isoFileStream))
                        {

                            string[] all = temp.Split('\n');
                            for (int i = 0; i < all.Length; i++)
                            {
                                if (all[i].CompareTo("null") != 0 && all[i].CompareTo("null1") != 0)
                                {
                                    if (all[i].CompareTo("") != 0)
                                        isoFileStream.WriteByte(Convert.ToByte(all[i]));
                                }
                                else
                                {
                                    if (all[i].CompareTo("null") == 0)
                                    {
                                        GlobalVar.iscomplete = true;
                                    }
                                    break;
                                }
                            }

                        }

                        GlobalVar.resume = false;
                    }
                    catch (Exception e)
                    {
                        GlobalVar.resume = true;
                    }

                }
            }
            else
            {
                GlobalVar.resume = true;
            }
            return GlobalVar.iscomplete;
        }
开发者ID:sauravmahajan,项目名称:CDN-WindowsApp,代码行数:82,代码来源:explorer.xaml.cs

示例4: 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

示例5: WriteThenRead

		public void WriteThenRead ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
			using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("moon", FileMode.Create, isf)) {
				byte [] data = new byte [2] { 0x00, 0x01 };
				fs.Write (data, 0, 1);
				fs.WriteByte (0xff);
			}
			using (IsolatedStorageFileStream fs = isf.OpenFile ("moon", FileMode.Open)) {
				byte [] data = new byte [1];
				Assert.AreEqual (1, fs.Read (data, 0, 1), "1");
				Assert.AreEqual (0x00, data[0], "0x00");
				Assert.AreEqual (0xff, fs.ReadByte (), "0xff");

				isf.Remove (); // this removed everything
				Assert.Throws (delegate { fs.Read (data, 1, 1); }, typeof (IsolatedStorageException), "Remove/Write"); // Fails in Silverlight 3
				Assert.Throws (delegate { fs.ReadByte (); }, typeof (IsolatedStorageException), "Remove/WriteByte");
				isf.Dispose ();
				Assert.Throws (delegate { fs.Read (data, 1, 1); }, typeof (ObjectDisposedException), "Dispose/Write");
				Assert.Throws (delegate { fs.ReadByte (); }, typeof (ObjectDisposedException), "Dispose/WriteByte");
			}
			isf = IsolatedStorageFile.GetUserStoreForApplication ();
			Assert.AreEqual (0, isf.GetFileNames ().Length, "Empty");
		}
开发者ID:dfr0,项目名称:moon,代码行数:24,代码来源:IsolatedStorageFileStreamTest.cs

示例6: Write

		private void Write (string filename)
		{
			byte[] buffer = new byte[8];
			using (IsolatedStorageFileStream write = new IsolatedStorageFileStream (filename, FileMode.Create, FileAccess.Write)) {
				Assert.IsFalse (write.CanRead, "write.CanRead");
				Assert.IsTrue (write.CanSeek, "write.CanSeek");
				Assert.IsTrue (write.CanWrite, "write.CanWrite");
				Assert.IsFalse (write.IsAsync, "write.IsAync");
				write.Write (buffer, 0, buffer.Length);
				write.Position = 0;
				write.WriteByte ((byte)buffer.Length);
				write.SetLength (8);
				write.Flush ();
				write.Close ();
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:IsolatedStorageFileStreamCas.cs

示例7: client_OpenReadCompleted

        private void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            IsolatedStorageFileStream fileStream = null;
            try
            {
                var fileName = FileSystem.ProfilePictureDirectory + UniqueId + ".jpg";
                var myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

                if (myIsolatedStorage.FileExists(fileName))
                    myIsolatedStorage.DeleteFile(fileName);

                fileStream = new IsolatedStorageFileStream(fileName, FileMode.Create, myIsolatedStorage);
                //var writer = new StreamWriter(fileStream);
                while (true)
                {
                    var byteData = e.Result.ReadByte();
                    if (byteData != -1)
                    {
                        fileStream.WriteByte((byte)byteData);
                    }
                    else
                    {
                        break;
                    }
                }
                //writer.Write(e.Result);
                fileStream.Close();
            }
            catch (Exception ex)
            {
                AppLog.WriteToLog(DateTime.Now, "Error downloading image. " + ex.Message, LogLevel.Error);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
        }
开发者ID:shahzadadil,项目名称:BirthdayReminderAndManager,代码行数:40,代码来源:FriendEntity.cs

示例8: button2_Click

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            GlobalVar.client.Send("1" + "\n");
            GlobalVar.client.Send(textDownload.Text + "\n");
            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            // Create a new folder and call it "MyFolder".
            myStore.CreateDirectory("MyFolder");
            string temp = GlobalVar.client.Receive();
            // Specify the file path and options.
            using (var isoFileStream = new IsolatedStorageFileStream("MyFolder\\"+textDownload.Text, FileMode.OpenOrCreate, myStore))
            {
                //Write the data
                using (var isoFileWriter = new StreamWriter(isoFileStream))
                {

                   /* bool done = false;
                    while (temp.CompareTo("null")!=0)
                    {
                        string[] all = temp.Split('\n');
                        for (int i = 0; i < all.Length; i++)
                        {
                            if (all[i].CompareTo("null") != 0)
                            {
                                isoFileWriter.WriteLine(all[i]);
                            }
                            else
                            {
                                done = true;
                                break;
                            }
                        }
                        if (done) break;

                        temp = GlobalVar.client.Receive();
                    }*/
                    bool done = false;
                    while (temp.CompareTo("null") != 0)
                    {
                        string[] all = temp.Split('\n');
                        for (int i = 0; i < all.Length; i++)
                        {
                            if (all[i].CompareTo("null") != 0)
                            {
                                if (all[i].CompareTo("") != 0)
                                isoFileStream.WriteByte(Convert.ToByte(all[i]));
                            }
                            else
                            {
                                done = true;
                                break;
                            }
                        }
                        if (done) break;

                        temp = GlobalVar.client.Receive();
                    }
                }
            }

            // Obtain the virtual store for the application.
            

            
                    
            NavigationService.Navigate(new Uri("/downloading.xaml", UriKind.Relative));
        }
开发者ID:sauravmahajan,项目名称:CDN-WindowsApp,代码行数:67,代码来源:login.xaml.cs


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