本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.ReadByte方法的具体用法?C# IsolatedStorageFileStream.ReadByte怎么用?C# IsolatedStorageFileStream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFileStream
的用法示例。
在下文中一共展示了IsolatedStorageFileStream.ReadByte方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
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 ();
}
}
示例2: 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");
}
示例3: button3_Click
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.";
}
}