从WPF中的“资源文件夹"中打开文件 [英] Open a file from Resource Folder in WPF

查看:507
本文介绍了从WPF中的“资源文件夹"中打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在制作一个应用程序,以从应用程序的资源目录中打开文件,当我在线发布该文件时,该文件将包含在项目中,
它不会安装在开始"菜单中,而是一个独立的应用程序,

在按钮上,单击我要打开包含在资源文件夹中的文件.

我到目前为止所拥有的是:

Hi,
I am making a application to open files from the resource directory of the application which would be included with the project when i publish it online,
It would not install in start menu and would be a standalone application,

On a Button Click i want to open a file which i have included in the resource folder.

what i have so far is:

private void button1_Click_2(object sender, RoutedEventArgs e)
{
    string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\test.txt";
    if (File.Exists(path))
    {
        Process.Start(new ProcessStartInfo(path));
    }
    else
    {
        MessageBox.Show("No file found"+path);
    }


但是当我单击它时,它指向我未包含在项目中的bin \ debug文件夹.

我已经在线设置了我的项目以进行测试,

http://setup.fastfixsupport.net/publish.htm

有人可以帮我吗?


But when i click it it points to bin\debug folder which i am not including in the project.

I have setup my project online for test at

http://setup.fastfixsupport.net/publish.htm

Can anyone help me with this ?

推荐答案

这可以帮助您 ^ ]
This may help you
WPF Application Resource, Content, and Data Files
[^]


这篇关于从WPF中的“资源文件夹"中打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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