如何从网页在服务器上运行ofc.exe? [英] How to run ofc.exe on the server from the web page?

查看:409
本文介绍了如何从网页在服务器上运行ofc.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我正在尝试编写将doc文件转换为docx的代码.据我所知,我可以为此使用ofc.exe,但不能从aspx页面运行它.

我正在冒充具有不受限制权限的用户(该用户在一组本地管理员中),但该文件未转换.奇怪的是,没有错误或输出生成.问题出在哪里?如果您有将doc转换为docx的更好方法-请告诉我! =)

我用于运行ofc.exe的代码如下:

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!");
}


之后,事件日志将具有条目:"OFC.exe输出:".

PS:操作系统是Windows Server 2008 x64,带有IIS7


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

P.S.: OS is Windows Server 2008 x64 with IIS7

推荐答案

您的ofc.ini文件是否可以使用所有参数...,请先将其检出,
没有问题就是代码.,

通过以下链接获取更多信息

从doc批量转换为docx [ ^ ]
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[^]


这篇关于如何从网页在服务器上运行ofc.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆