WriteByte() public méthode

public WriteByte ( byte value ) : void
value byte
Résultat void
 public void Save()
 {
     using (IsolatedStorageFileStream fs = container.CreateFile(LocalSettings)) {
         // note: SL seems to prepend a line with a fully qualified name for System.Object + CRLF
         byte[] header = System.Text.Encoding.UTF8.GetBytes(typeof(object).AssemblyQualifiedName);
         fs.Write(header, 0, header.Length);
         fs.WriteByte(13);
         fs.WriteByte(10);
         // and does not seems to need it when reading back...
         DataContractSerializer ser = new DataContractSerializer(settings.GetType());
         ser.WriteObject(fs, settings);
     }
 }
		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);
			}
		}
        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;
        }
        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();
                    }
                }
            }
        }
		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");
			}
		}
		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");
		}
		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 ();
			}
		}
        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();
                }
            }
        }
        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));
        }