using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = Application.StartupPath + @"\test01.DAT";
//byte配列へ変換
FileStream fsr = new FileStream( path,FileMode.Open,FileAccess.Read);
byte[] data = new byte[fsr.Length];
fsr.Read(data, 0, data.Length);
fsr.Close();
fsr.Dispose();
data[3] = 66;
//上書き更新
FileStream fsw = new FileStream(path, FileMode.Create, FileAccess.Write);
fsw.Write(data, 0, data.Length);
fsw.Close();
fsw.Dispose();
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkNvbXBvbmVudE1vZGVsOwp1c2luZyBTeXN0ZW0uRGF0YTsKdXNpbmcgU3lzdGVtLkRyYXdpbmc7CnVzaW5nIFN5c3RlbS5MaW5xOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLldpbmRvd3MuRm9ybXM7CnVzaW5nIFN5c3RlbS5JTzsKCm5hbWVzcGFjZSBXaW5kb3dzRm9ybXNBcHBsaWNhdGlvbjEKewogICAgcHVibGljIHBhcnRpYWwgY2xhc3MgRm9ybTEgOiBGb3JtCiAgICB7CiAgICAgICAgcHVibGljIEZvcm0xKCkKICAgICAgICB7CiAgICAgICAgICAgIEluaXRpYWxpemVDb21wb25lbnQoKTsKICAgICAgICB9CgogICAgICAgIHByaXZhdGUgdm9pZCBidXR0b24xX0NsaWNrKG9iamVjdCBzZW5kZXIsIEV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgc3RyaW5nIHBhdGggPSBBcHBsaWNhdGlvbi5TdGFydHVwUGF0aCArIEAiXHRlc3QwMS5EQVQiOwoKICAgICAgICAgICAgLy9ieXRl6YWN5YiX44G45aSJ5o+bCiAgICAgICAgICAgIEZpbGVTdHJlYW0gZnNyID0gbmV3IEZpbGVTdHJlYW0oIHBhdGgsRmlsZU1vZGUuT3BlbixGaWxlQWNjZXNzLlJlYWQpOwogICAgICAgICAgICBieXRlW10gZGF0YSA9IG5ldyBieXRlW2Zzci5MZW5ndGhdOwogICAgICAgICAgICBmc3IuUmVhZChkYXRhLCAwLCBkYXRhLkxlbmd0aCk7CiAgICAgICAgICAgIGZzci5DbG9zZSgpOwogICAgICAgICAgICBmc3IuRGlzcG9zZSgpOwogICAgICAgICAgICBkYXRhWzNdID0gNjY7CiAgICAgICAgICAgIAogICAgICAgICAgICAvL+S4iuabuOOBjeabtOaWsAogICAgICAgICAgICBGaWxlU3RyZWFtIGZzdyA9IG5ldyBGaWxlU3RyZWFtKHBhdGgsIEZpbGVNb2RlLkNyZWF0ZSwgRmlsZUFjY2Vzcy5Xcml0ZSk7CiAgICAgICAgICAgIGZzdy5Xcml0ZShkYXRhLCAwLCBkYXRhLkxlbmd0aCk7CiAgICAgICAgICAgIGZzdy5DbG9zZSgpOwogICAgICAgICAgICBmc3cuRGlzcG9zZSgpOwogICAgICAgIH0KICAgIH0KfQo=