如何获取resource.resx的路径 [英] how to get path of resource.resx

查看:128
本文介绍了如何获取resource.resx的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我建立了一个Windows窗体应用程序,其中从resource.resx文件中提取了一些字符串.在我自己的PC上运行时,我可以给出资源文件的路径,例如c:/myapp/resources.resx,但是在其他计算机上部署并安装该文件后,代码将如何知道该文件的路径.
我的意思是,有没有类似的方法,例如server.mappath(Web应用程序).
请帮忙.
到目前为止,我已经尝试过:

hi all

i have built an windows form application,in which some strings are fetched from resource.resx file. while running in my own pc i can give the path of resource file like c:/myapp/resources.resx but after deploying and installing it on other computer how the code will know the path of the file.
i mean, is there any similiar method like server.mappath (web applications).
please help.
i have tried so far:

string appDir = System.Reflection.Assembly.GetExecutingAssembly().Location;
//string sResxPath = @"C:\Users\PC1\Documents\Visual Studio 2008\Projects\Instantsms\Instantsms\contacts.resx";
string sResxPath = System.IO.Path.Combine(appDir, "contacts.resx");

推荐答案

如果您构建了应用程序,则将创建exe.
这些资源嵌入在您的EXE文件中.
这些资源在运行时不作为单独的文件存在.
所以不必这样做....
If you built the application, the exe is created.
These resources are embedded in your EXE file.
These resources does not exist as separate files at runtime.
So need not to do....


这篇关于如何获取resource.resx的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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