写入C#中的所有位

0 .net c# io file

如何使用c#编写文件的所有位?例如,将0写入所有位

请提供样品

Dan*_*ker 6

我不确定你为什么要这样做,但这会覆盖一个文件,该文件的长度相同,但包含的字节值为零:

File.WriteAllBytes(filePath, new byte[new FileInfo(filePath).Length]);
Run Code Online (Sandbox Code Playgroud)