I'm trying to convert a doc to html and this is the code I use. The problem is that I have no exception but I did not create the file. I've tried various alternatives but do not know how to proceed.
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
//check if file is ok
if (file != null && file.ContentLength > 0)
{
var path = Path.Combine(Server.MapPath("~/App_Data/"),
System.IO.Path.GetFileName(file.FileName));
file.SaveAs(path);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = ("soffice.exe");
psi.Arguments = string.Format("--headless --convert-to htm:HTML --outdir " + Server.MapPath("~/App_Data/batch/") + " \"{0}\"", path);
psi.UseShellExecute = false;
Process proc = new Process();
proc.StartInfo = psi;
proc.Start();
proc.WaitForExit();
}
return View();
}
I've updated the code :
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
//check if file is ok
if (file != null && file.ContentLength > 0)
{
var path = Path.Combine(Server.MapPath("~/App_Data/"),
System.IO.Path.GetFileName(file.FileName));
file.SaveAs(path);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Path.Combine(Server.MapPath("~/App_Data/LOP/App/libreoffice/program/"), "soffice.exe");
psi.Arguments = string.Format("--headless --convert-to htm:HTML --outdir " + Server.MapPath("~/App_Data/batch/") + " \"{0}\"", path);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
Process proc = new Process();
proc.StartInfo = psi;
proc.Start();
string myString = proc.StandardOutput.ReadToEnd();
Console.WriteLine(myString);
proc.WaitForExit();
var exitCode = proc.ExitCode;
}
return View();
}
But Exitcode still 0 and myString is empty :(
--SOLUTION-- All code are ok! a process of libroffice was left hanging in memory and then every other request appending without give a results, the strange thing is that libreoffice continues to give exitcode 0 to all process in memory