I'm quite new to C# and I need to write a file (grub) on an EXt2 linux partition from windows 7.
What is the good way to do such thing? Do I need to mount the partition with external program?
I'm quite new to C# and I need to write a file (grub) on an EXt2 linux partition from windows 7.
What is the good way to do such thing? Do I need to mount the partition with external program?
I think you need to mount it with an external program such as: http://www.fs-driver.org/
Mount the drive using a a driver like FS-driver and then write to it using standard C# file writing techniques.
您可以使用 Ext2Fsd 在 windows 中挂载分区,然后像任何其他分区一样写入。
如果您在 Windows 下使用 Total Commander,可用插件之一是用于访问 ext2/3/4。这里可能已经提到过,但它使得从 Windows 访问 Linux 几乎是透明的。我现在没有安装它,否则我会看看名字。
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();