Closed thuongthinh closed 1 year ago
You'd better copy your code to explain. SharpExt4 is just a library to provide the ext4 fs read/write.
Here my code:
Form A:
private void frmLogin_Load(object sender, EventArgs e)
{
disk = ExtDisk.Open(3);
fs = ExtFileSystem.Open(disk, disk.Partitions[0]);
}
private void btnLogin_Click(object sender, EventArgs e)
{
var file = fs.OpenFile("/USB/Test.txt", FileMode.Open, FileAccess.Read);
var filelen = file.Length;
var buf = new byte[filelen];
var count = file.Read(buf, 0, (int)filelen);
file.Close();
var content = Encoding.Default.GetString(buf);
if(content == "123")
{
// Call Form B
frmMain frm = new frmMain(DeviceID);
frm.Show();
this.Hide();
}
}
Form B: private void frmMain_Load(object sender, EventArgs e) { disk = ExtDisk.Open(3); fs = ExtFileSystem.Open(disk, disk.Partitions[0]); listFolderFile.DataSource = ListAllFiles(fs); // Error here! }
static List
return result;
}
If you remove function, ListAllFiles(ExtFileSystem), and move the logic into formload, what do you get?
i remove function, ListAllFiles(ExtFileSystem), then not error. Rrror "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" in the command: de = ext4_dir_entry_next(&d); in function ListAllFiles(ExtFileSystem)
fs.GetDirectories("/", "*", SearchOption.AllDirectories)
This will list all the files and directories under the root directory recursively!!! It will be massive amount of strings. This will cause out of memory!!!! Are you sure to use this way?
Try not to do this.
Thank!
Hello! My project has 2 winform, Form A used the command: fs.OpenFile(); it's ok, but from Form A call Form B, get error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" in the command: fs.GetDirectories(); Help me! Thanks!