C#定位文件位置并修改字节数据

http://blog.sina.com.cn/s/blog_94a1fe540102ympb.html

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace fixMp4
{
    class Program
    {
       static void Main(string[] args)
       {
          Console.WriteLine("hello world!");
           string mp4file = "D:\\fixTool\\cannotPlayCs.mp4";
           FileStream writeStream = File.OpenWrite(mp4file);
           byte[] newData = new byte[4];
           newData[0] = 0x00;
           newData[1] = 0x50;
           newData[2] = 0x00;
           newData[3] = 0x08;
          writeStream.Seek(32, SeekOrigin.Begin);
          writeStream.Write(newData, 0, newData.Length);
          writeStream.Close();
       }
    }
}
 
posted @ 2021-06-01 14:29  China Soft  阅读(391)  评论(0编辑  收藏  举报