[英]C# write to ext2 linux partition from Windows
我对 C# 很陌生,我需要在 Windows 7 的 EXt2 linux 分区上编写一个文件 (grub)。
做这种事情的好方法是什么? 我需要用外部程序挂载分区吗?
我认为您需要使用外部程序安装它,例如: http : //www.fs-driver.org/
如果您在 Windows 下使用 Total Commander,可用的插件之一是用于访问 ext2/3/4。 它可能已经在这里提到过,但它使得从 Windows 访问 Linux 几乎是透明的。 我现在没有安装它,否则我会看名字。
您可以使用 Ext2Fsd 在 Windows 中挂载分区,然后像写入任何其他分区一样写入。
SharpExt4 可以帮助您进行 Linux 文件系统的读写。
一个 .Net 库,提供对 Linux ext2/ext3/ext4 文件系统的完全访问(读/写)
这是 GitHub 链接https://github.com/nickdu088/SharpExt4
//Open EXT4 SD Card
//Here is SD Card physical disk number. you can get from Windows disk manager
ExtDisk SharpExt4.ExtDisk.Open(int DiskNumber);
//In your case FAT32 is 1st one, ext4 is 2nd one
//Open EXT4 partition
var fs = ExtFileSystem.Open(disk.Parititions[1]);
//Create /home/pi/file.conf file for write
var file = fs.OpenFile("/home/pi/file.conf", FileMode.Create, FileAccess.Write);
var hello = "Hello World";
var buf = Encoding.ASCII.GetBytes(hello);
//Write to file
file.Write(buf, 0, buf.Length);
file.Close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.