Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert files to byte array memory objects
public static string AddFilesToTransaction(RestService rs, string docNbr, string filePath, string fileName, string entity)
{
string result = "#UPLOADING DOCS";
try
{
byte[] filedata;
using (FileStream file = File.Open(filePath, FileMode.Open))
{
filedata = new byte[file.Length];
file.Read(filedata, 0, filedata.Length);
//Add the file
Stream fileToAttach = new MemoryStream(filedata);
result = rs.PutFile(entity, docNbr, fileName, fileToAttach);
}
}
catch (Exception msg)
{
result = msg.Message;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment