简体   繁体   English

在C#中以编程方式安装字体

[英]Install font programmatically in c#

I have c# web application project in which i want to install user uploaded .ttf font files into system. 我有一个C#Web应用程序项目,我想在其中将用户上传的.ttf字体文件安装到系统中。

I am using FontReg for the same. 我使用相同的FontReg We can execute by using command line parameters as D:\\TFS\\Dev\\Sprint_18_III\\UI\\Web\\FontFiles>FontReg /copy so it will install all .ttf files present in directory 我们可以使用以下命令行参数执行D:\\TFS\\Dev\\Sprint_18_III\\UI\\Web\\FontFiles>FontReg /copy这样它将安装目录中存在的所有.ttf文件

same this i am trying to achieve in c# code 我试图在C#代码中实现的效果相同

using (Process process = new Process())
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.Verb = "runas";
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "D:\\TFS\\Dev\\Sprint_18_III\\UI\\Web\\FontFiles\\FontReg.exe"; 
                startInfo.Arguments = "/copy";
                process.StartInfo = startInfo;
                process.Start();
                process.WaitForExit();
            }

Process gets completed but font doesn't install. 处理完成,但未安装字体。 What i am missing here ? 我在这里想念什么?

  • I dont want to give admin rights to entire web application running. 我不想授予整个Web应用程序运行的管理员权限。 It should be specific to one method only. 它应该只针对一种方法。

我认为您正在使用特权不足的用户运行该程序... IIS用户,默认情况下为“网络授权”,并且该帐户无法在Windows目录中执行更改...请尝试使用管理员帐户运行该程序。 ..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM