Advertisement
Advertisement
| 08.14.2008 at 07:30AM PDT, ID: 23648236 | Points: 125 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: |
public static bool writeBinary(BinaryWriter bw, FileStream myFile)
{
try
{
long ii = 0;
byte[] myData = new byte[myFile.Length];
//myFile.Read(myData,0,Convert.ToInt32(myFile.Length));
while(ii < myFile.Length)
{
myData[ii] = (byte)myFile.ReadByte(); //br.ReadByte();
//bw.Write(
//bw.Flush();
ii++;
}
bw.Write(myData);
bw.Flush();
return true;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
}
public static bool readBinary(BinaryReader br, String fileName, int byteSize)
{
try
{
String storPath = fileName;
if(File.Exists(storPath))
File.Delete(storPath);
FileStream fs = new FileStream(storPath,FileMode.CreateNew, FileAccess.Write);
BinaryWriter sw = new BinaryWriter(fs);
//for(int ii = 0; ii < byteSize; ii++)
//{
// byte inChar = (byte)br.ReadByte();
// sw.Write(inChar);
//}
byte[] byteData = br.ReadBytes(byteSize);
sw.Write(byteData);
sw.Close();
fs.Close();
return true;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
}
|