Convert files to byte array memory objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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