I am using the library MPXJ which works great but I now want the ability for users to upload their own file (asp.net-mvc site) and it comes on the server side form post as a HttpPostedFileBase and I then I convert to a memory stream using:
var stream = new MemoryStream();
httpPostedFile.InputStream.CopyTo(stream);
Given that, I am trying to figure out how i can read it in as a MemoryStream (versus a file location on disk)
Right now I have something like this:
public ProjectFile Import(string filePathandName)
{
MPPReader reader = new MPPReader();
ProjectFile project = reader.read(filePathandName);
and i wanted to have something like this:
public ProjectFile Import(MemoryStream stream)
{
MPPReader reader = new MPPReader();
ProjectFile project = reader.read(stream);
Is this possible "natively" or do i need to save the file on my server and then read in from there (trying to avoid that option)?
The MPPReader.Read()
method only accepts 4 types of parameters, none of which are a MemoryStream
and all but one seem to be types that are defined within the library itself:
You are currently using the string
parameter as it expects a path, however it seems the closest that you might get would be to try to copy your existing MemoryStream
object to the InputStream
type found within the library and using that (if that type of support exists).