Reputation: 2763
I want to get the size of file in isolated storage as bytes. also need to read that file as block of 1024 bytes each. How can I do that?
Upvotes: 1
Views: 655
Reputation: 742
public static IsolatedStorageFileStream OpenFile(string filePath)
{
IsolatedStorageFileStream fileStream = null;
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!store.FileExists(filePath))
{
return fileStream;
}
else
{
fileStream = store.OpenFile(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
}
return fileStream;
}
void ReadFile()
{
using (var streamReader = OpenFile(filePath))
{
using (BinaryReader reader = new BinaryReader(streamReader))
{
byte[] buffer = new byte[1024];
int fileLen = (int)reader.BaseStream.Length;
int readCount=0;
while (fileLen > 0)
{
readCount = reader.Read(buffer, 0, buffer.Length);
fileLen = fileLen - readCount;
//Do what ever with buffer
}
}}}
Upvotes: 1