简体   繁体   English

C# 从 Windows 写入 ext2 linux 分区

[英]C# write to ext2 linux partition from Windows

I'm quite new to C# and I need to write a file (grub) on an EXt2 linux partition from windows 7.我对 C# 很陌生,我需要在 Windows 7 的 EXt2 linux 分区上编写一个文件 (grub)。

What is the good way to do such thing?做这种事情的好方法是什么? Do I need to mount the partition with external program?我需要用外部程序挂载分区吗?

我认为您需要使用外部程序安装它,例如: http : //www.fs-driver.org/

使用FS-driver等驱动程序挂载驱动,然后使用标准 C# 文件写入技术写入驱动器

If you use Total Commander under Windows, one of the available plugins is for accessing ext2/3/4.如果您在 Windows 下使用 Total Commander,可用的插件之一是用于访问 ext2/3/4。 It's probably already been mentioned here but it makes accessing Linux from Windows almost transparent.它可能已经在这里提到过,但它使得从 Windows 访问 Linux 几乎是透明的。 I don't have it installed right now or I'd look at the name.我现在没有安装它,否则我会看名字。

You can use Ext2Fsd to mount the partition in windows, and then write to as you would any other partition.您可以使用 Ext2Fsd 在 Windows 中挂载分区,然后像写入任何其他分区一样写入。

EXT2FSD Home Page EXT2FSD 主页

SharpExt4 may help you with Linux file system read and write. SharpExt4 可以帮助您进行 Linux 文件系统的读写。

A .Net library to provide full access (read/write) to Linux ext2/ext3/ext4 filesystem一个 .Net 库,提供对 Linux ext2/ext3/ext4 文件系统的完全访问(读/写)

Here is the GitHub link https://github.com/nickdu088/SharpExt4这是 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();

How to use SharpExt4 to access Raspberry Pi SD Card Linux partition如何使用SharpExt4访问树莓派SD卡Linux分区

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM