我有一个树莓派SD卡有2个分区,第一个是Fat32,第二个是EXT4分区,现在我想访问C#中的EXT4分区上的文件,以写入,编辑,读取和创建文件。我已经用System.IO尝试了一些方法来获取目录等(非常基本的东西)。那么,有没有人知道有没有办法用C#代码访问EXT4分区/磁盘呢?
我使用的是Windows 10操作系统。
它应该是这样工作的:File.Create("path to the Disk(J:)/rootfs/home/pi/file.conf");
但是,我得到一个错误:System.IO.IOException: "There is no recognized file system on the data carrier
发布于 2021-04-02 05:09:20
SharpExt4可以帮助你读写Linux文件系统。
提供对Linux ext2/ext3/ext4文件系统的完全访问(读/写)的.Net库
这是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
https://stackoverflow.com/questions/66409065
复制相似问题