OleDbConnection Mycon = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=MyDb.mdb");<br /> FileStream fs = new FileStream(filename,FileMode.Open, FileAccess.Read);<br /> BinaryReader br = new BinaryReader(fs);<br /> byte[] mywave = br.ReadBytes((int)fs.Length);<br /> br.Close();<br /> fs.Close();</p><p> Mycon.Open();<br /> string sql = "insert into MyDataBase(wav,MyWord) VALUES (@wav,'"+textBox1.Text.Trim()+"')";<br /> OleDbCommand cmd = new OleDbCommand(sql, Mycon);<br /> cmd.Parameters.Add("@wav", OleDbType.Binary, photo.Length).Value = mywave ;<br /> cmd.ExecuteNonQuery();<br /> Mycon.Close();</p><p>#region 對文字檔的讀寫<br />FileStream fs = new FileStream(@"r:''txt.txt", System.IO.FileMode.OpenOrCreate,<br />System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);<br />FileStream f = File.Open(@"r:''f.txt", FileMode.OpenOrCreate,<br />FileAccess.ReadWrite, FileShare.ReadWrite);<br />string s = "秋偉光lov.09823p''''=!@#%.;";<br />byte[]inb = System.Text.Encoding.UTF8.GetBytes(s); //和下面一樣這個容易理解<br />//byte[] inb = new UTF8Encoding(true).GetBytes(s);//和上面的一樣效果<br />fs.Write(inb, 0, inb.Length);<br />fs.Flush(); //清空緩衝<br />fs.Close();<br />FileStream ff = File.OpenRead(@"r:''txt.txt");<br />byte[]a = new byte[ff.Length];<br />ff.Read(a, 0, (int)a.Length);<br />f.Write(a, 0, (int)ff.Length);<br />ff.Close();<br />f.Close();<br />#endregion</p><p>#region 對二進位檔案的讀寫<br />//System.IO.BinaryReader: 讀二進位檔案<br />//System.IO.BinaryWriter: 寫二進位檔案<br />//FileStream fs1 = new FileStream(@"r:''gif.gif",FileMode.OpenOrCreate,FileAccess.ReadWrite);<br />//FileStream fs2 = new FileStream(@"r:''p1.bmp",FileMode.OpenOrCreate,FileAccess.ReadWrite);<br />//FileStream fw = new FileStream(@"r:''new.txt",FileMode.OpenOrCreate,FileAccess.ReadWrite);<br />//BinaryReader br = new BinaryReader(fs1);<br />//BinaryWriter bw = new BinaryWriter(fw);<br />//bw.Write(br.ReadInt32());<br />#endregion