forked from jordanlytle/SmbAbstraction
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
We were getting a sporadic error about "Not enough credits" when trying to write larger images to the fileshare. Troy's best guess is that the Windows Native SMB has better credit handling and scaling. Adam is unsure if the problem is Windows or Linux specific. It might be Windows-specific.
// Old Logic: fs.File.WriteAllBytes(filename, data);
// Open a stream instead of writing all bytes at once. Use 64 KB chunks for SMB efficiency
const int chunkSize = 64 * 1024;
using (var stream = fs.File.OpenWrite(filename))
{
int offset = 0;
while (offset < data.Length)
{
int bytesToWrite = Math.Min(chunkSize, data.Length - offset);
stream.Write(data, offset, bytesToWrite);
offset += bytesToWrite;
}
}
Metadata
Metadata
Assignees
Labels
No labels