ReadByte() public method

public ReadByte ( ) : int
return int
		private void Read (string filename)
		{
			byte[] buffer = new byte[8];
			using (IsolatedStorageFileStream read = new IsolatedStorageFileStream (filename, FileMode.Open, FileAccess.Read)) {
				Assert.AreEqual (8, read.Length, "Length");
				Assert.AreEqual (0, read.Position, "Position");
				Assert.IsTrue (read.CanRead, "read.CanRead");
				Assert.IsTrue (read.CanSeek, "read.CanSeek");
				Assert.IsFalse (read.CanWrite, "read.CanWrite");
				Assert.IsFalse (read.IsAsync, "read.IsAync");
				Assert.AreEqual (buffer.Length, read.ReadByte (), "ReadByte");
				read.Seek (0, SeekOrigin.Begin);
				Assert.AreEqual (buffer.Length, read.Read (buffer, 0, buffer.Length), "Read");
				read.Close ();
			}
		}
Exemplo n.º 2
0
		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");
		}
Exemplo n.º 3
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            // Obtain a virtual store for the application.
            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
            // Specify the file path and options.
                GlobalVar.client.Send(""+2+"\n");
                GlobalVar.client.Send(RemoteUpload.Text + "\n");
                using (var isoFileStream = new IsolatedStorageFileStream("MyFolder\\"+RemoteUpload.Text, FileMode.Open, myStore))
            {
                // Read the data.
                using (var isoFileReader = new StreamReader(isoFileStream))
                {
                    int temp_send=isoFileStream.ReadByte();
                    while (temp_send !=-1)
                    {
                        GlobalVar.client.Send(temp_send+"\n");
                        temp_send = isoFileStream.ReadByte();
                    }
                    GlobalVar.client.Send("null"+"\n");
                }
            }
               // GlobalVar.client.Send("-1"+ "\n");

        }
        catch
        {
            // Handle the case when the user attempts to click the Read button first.
            //txtRead.Text = "Need to create directory and the file first.";
        }
      }