Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi! I'm trying to write a code which will converts doc files to docx. As far as I know, I can use ofc.exe for this purposes, but I can't run it from an aspx page.

I'm impersonating the user who has unrestricted rights (user is in a group of the local administrators), but the file is not converted. The strange thing is, that no error or output is generated. Where can be the problem? If you have a better way to convert doc to docx - please, tell me! =)

The code I use to run the ofc.exe is the following:
Process ofcProcess = new Process();
ofcProcess.StartInfo = new ProcessStartInfo();
ofcProcess.StartInfo.FileName = ofcLocation + @"\ofc.exe";
ofcProcess.StartInfo.WorkingDirectory = ofcLocation;
ofcProcess.StartInfo.UseShellExecute = false;
ofcProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
ofcProcess.StartInfo.RedirectStandardOutput = true;
ofcProcess.Start();
System.IO.StreamReader myOutput = ofcProcess.StandardOutput;
string m_output = myOutput.ReadToEnd();
ofcProcess.WaitForExit();
if (ofcProcess.HasExited)
{
    System.Diagnostics.EventLog.WriteEntry("MyEventLog", "OFC.exe output:\r\n" + m_output);
}
else
{
    System.Diagnostics.EventLog.WriteEntry("MyEventLog", "OFC.exe output:\r\nProcess haven't existed!");
}

After that the event log has entry: "OFC.exe output:".

P.S.: OS is Windows Server 2008 x64 with IIS7
Posted
Updated 24-Oct-10 23:23pm
v2

1 solution

Is your ofc.ini file is OK with all parameters..., check it out first ,
There is no Problem is code.,

Go through the below link for more Info

Bulk Convertion from doc to Docx[^]
 
Share this answer
 
Comments
BlackBar 25-Oct-10 5:19am    
When I run the OFC.exe from CMD - all is working as expected, so the ofc.ini file is correct.
Rajesh Anuhya 25-Oct-10 6:03am    
Check your ofcLocation is correctly setting to your ofcProcess.StartInfo.WorkingDirectory
BlackBar 25-Oct-10 6:18am    
ofcLocation is correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900