Ejemplo n.º 1
0
 public byte[] ReadBlock(LocalBlockInfo blockLocal)
 {
     byte[] data = new byte[blockLocal.Size];
     using (FileStream stream = File.Open(blockLocal.AbsFilePath, FileMode.Open))
     {
         try
         {
             stream.Position = blockLocal.Position;
             int read = stream.Read(data, 0, ExchUtils.StandardBlockSize);
             if (read == 0)
             {
                 throw new Exception("read == 0");
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
         return data;
     }
 }
Ejemplo n.º 2
0
 public void WriteBlock(LocalBlockInfo blockLocal, byte[] data)
 {
     using (FileStream stream = File.Open(blockLocal.AbsFilePath, FileMode.Open))
     {
         try
         {
             stream.Position = blockLocal.Position;
             stream.Write(data, 0, data.Length);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
     }
 }