Skip to content

Instantly share code, notes, and snippets.

@Thomas-Giaroli
Created June 23, 2023 12:56
Show Gist options
  • Save Thomas-Giaroli/6c1553cce846ff2c5c43b2a4a7b1d026 to your computer and use it in GitHub Desktop.
Save Thomas-Giaroli/6c1553cce846ff2c5c43b2a4a7b1d026 to your computer and use it in GitHub Desktop.
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