如何从服务器获取我的解决方案中的文件夹

问题描述:





在我的项目中使用加密方法。对于加密,我有一个包含公钥的公共文件(.asc)。我将此文件存储在我的解决方案的文件夹中。路径将像(我的解决方案\ProjectName \FolderName \ publicFile.asc)。该应用程序是一个控制台应用程序。



当我在其中一个服务器中部署此解决方案并运行批处理作业时,我无法找到我的publicFile路径。



我知道使用AppDomain.CurrentDomain.BaseDirectory会给出bin文件夹。但我想要的是一个解决方案文件夹。我如何实现这一目标?请帮帮我。



[我还使用了Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))来获取路径,它在本地但不在服务器中正常工作]

Hi,

In my project am using encryption method. For encryption, i have a public file(.asc) which contain public key. I stored this file in file folder of my solution. Path will be like (My solution\ProjectName\FolderName\publicFile.asc). The application is a console application.

When i deploy this solution in one of the server and run the batch job am not able to locate my publicFile path.

I know by using AppDomain.CurrentDomain.BaseDirectory will give the bin folder. But what i want is a solution folder. How do i achieve this? Please help me on this.

[I also used Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) to get the path, its working fine in local but not in server]

Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase



为什么?在服务器上,可执行文件被复制到临时文件夹并在那里执行。


Why? On the server, the executable is copied to a temporary folder and executed there.