Skip to content

Instantly share code, notes, and snippets.

@Thomas-Giaroli
Created June 23, 2023 12:56
public NtStatus ReadFile(string fileName, byte[] buffer, out int bytesRead, long offset, IDokanFileInfo info)
{
if (info.Context is Attachment att)
{
if (att.rawData != null)
{
Console.WriteLine(att.rawData.Length);
Byte[] arr = Convert.FromBase64String(att.rawData);
bytesRead = Math.Min(buffer.Length, (arr.Length - (int)offset));
Array.Copy(arr, offset, buffer, 0, bytesRead); //The error happens here, because of the Math.min just a line up.
if ((int)offset + bytesRead >= arr.Length) //don't mind this if, it's for my caching system.
alreadyIncrementated = false;
return DokanResult.Success;
}
bytesRead = 0;
return DokanResult.Unsuccessful;
}
bytesRead = 0;
return DokanResult.Unsuccessful;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment