我试图打开它时找不到文件

时间:2022-06-05 20:33:50

I'm trying to open the certificate file:

我正在尝试打开证书文件:

//path to file
static string KKBpfxFile = 
    Path.Combine(HostingEnvironment.ApplicationPhysicalPath,
                 ConfigurationManager.AppSettings["CertFolder"], 
                 "cert.pfx");

_logger.Debug(KKBpfxFile);

X509Certificate2 KKbCert = new X509Certificate2(KKBpfxFile, KKBpfxPass);

But, I get exception file is not found. In the log file contais the following path:

但是,我找不到异常文件。在日志文件中包含以下路径:

C:\inetpub\wwwroot\msite\Certificates\cert.pfx

C:\的Inetpub \ wwwroot的\ msite \证书\ cert.pfx

I open this path in the Explorer and all it's ok. The file is exist.
Where is a problem?

我在资源管理器中打开此路径,一切正常。该文件存在。哪里有问题?

PS. I gave all (read, write and other) permission to this folder to ALL group.
PS2. This is problem only on production server. On my local machine is works.

PS。我将此文件夹的所有(读,写和其他)权限授予了所有组。 PS2。这只是生产服务器上的问题。在我的本地机器上工作。

2 个解决方案

#1


1  

Try to put a File.Exists() check before the call to the constructor.

尝试在调用构造函数之前进行File.Exists()检查。

Also there still might be an issue with access rights depending on what user the application pool is running on, but if you set access rights to "Everyone" it should work. Still...double-check that on the production server.

此外,访问权限仍然可能存在问题,具体取决于运行应用程序池的用户,但如果您将访问权限设置为“Everyone”,则应该可以使用。仍然......仔细检查生产服务器上的内容。

Also as a further step you could check the ACL of the file and see if you have read rights to it before calling the constructor and even further still, load the file into a byte array and call the constructor with the byte array as arg.

另外,作为进一步的步骤,您可以检查文件的ACL,并在调用构造函数之前查看您是否具有读取权限,甚至还可以将文件加载到字节数组中,并使用字节数组作为arg调用构造函数。

#2


0  

use procexp.exe and give the path in the exe. I will say you which program has locked your file. Request the program to relase it.. Dont kill it as it is production server.

使用procexp.exe并在exe中给出路径。我会说你哪个程序锁定了你的文件。请求程序重新启用它。不要杀死它,因为它是生产服务器。

Procexp can be found in your local machine/downloaded from microsoft. copy tat exe to produciton server and run from there

Procexp可以在本地机器上找到/从microsoft下载。将tat exe复制到produciton服务器并从那里运行

#1


1  

Try to put a File.Exists() check before the call to the constructor.

尝试在调用构造函数之前进行File.Exists()检查。

Also there still might be an issue with access rights depending on what user the application pool is running on, but if you set access rights to "Everyone" it should work. Still...double-check that on the production server.

此外,访问权限仍然可能存在问题,具体取决于运行应用程序池的用户,但如果您将访问权限设置为“Everyone”,则应该可以使用。仍然......仔细检查生产服务器上的内容。

Also as a further step you could check the ACL of the file and see if you have read rights to it before calling the constructor and even further still, load the file into a byte array and call the constructor with the byte array as arg.

另外,作为进一步的步骤,您可以检查文件的ACL,并在调用构造函数之前查看您是否具有读取权限,甚至还可以将文件加载到字节数组中,并使用字节数组作为arg调用构造函数。

#2


0  

use procexp.exe and give the path in the exe. I will say you which program has locked your file. Request the program to relase it.. Dont kill it as it is production server.

使用procexp.exe并在exe中给出路径。我会说你哪个程序锁定了你的文件。请求程序重新启用它。不要杀死它,因为它是生产服务器。

Procexp can be found in your local machine/downloaded from microsoft. copy tat exe to produciton server and run from there

Procexp可以在本地机器上找到/从microsoft下载。将tat exe复制到produciton服务器并从那里运行

相关文章