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(); } } }