How to write data at a particular position in c#?

后端 未结 4 708

I am making an application in c#. In that application I have one byte array and I want to write that byte array data to particular position.

Here i used the followin

4条回答
  •  猫巷女王i
    2020-12-06 06:56

    Never try to write binary data as strings, like you do. It won't work correctly. Write binary data as binary data. You can use Stream for that instead of StreamWriter.

    using (Stream stream = new FileStream(fileName, FileMode.OpenOrCreate))
    {
        stream.Seek(1000, SeekOrigin.Begin);
        stream.Write(Data, 0, Data.Length);
    }
    

提交回复
热议问题