如何从服务器获取我的解决方案中的文件夹 [英] How Do I Get A Folder In My Solution From Server

查看:62
本文介绍了如何从服务器获取我的解决方案中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的项目中使用加密方法。对于加密,我有一个包含公钥的公共文件(.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.


这篇关于如何从服务器获取我的解决方案中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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