在带有C#代码的vb20008中单击打开后,如何从浏览窗口中打开内容 [英] How to open an content from browse window after click an open in vb20008 with c# code

查看:63
本文介绍了在带有C#代码的vb20008中单击打开后,如何从浏览窗口中打开内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码来打开按钮,但是单击打开"按钮后未在浏览器窗口中打开或显示任何内容,因此请帮助我从浏览器窗口中读取和打开文件

I used this code for button to open but in browse window after click on open button not opening or displaying any content so help me to read and open a file from browse window

public string userSelectedFilePath
        {
            get
            {
                return tbFilePath.Text;
            }
            set
            {
                tbFilePath.Text = value;
            }
        }

        
        private void Browse_Click(object sender, EventArgs e)
        {
            LoadNewFile();
        }
        private void LoadNewFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            System.Windows.Forms.DialogResult dr = ofd.ShowDialog();
            if (dr == DialogResult.OK)
            {
                userSelectedFilePath = ofd.FileName;

            }
        }

And i used this for menustrip and problem is same <pre lang="c#"> OpenFileDialog fld = new OpenFileDialog();
            fld.ShowDialog();


请为编码和打开文件内容而大声疾呼这不适用于Web应用程序,这是针对Windows 7浏览窗口,单击打开按钮后应打开并显示文件中的内容
谢谢您


please hlep for coding and opening an file content This is for not web application, this is for windows 7 browse window on click on open button the content in the file should be opened and displayed
Thank You

推荐答案

当您谈论浏览窗口"时,您是说这是一个Web应用程序吗?而这段代码在后面的代码中?如果是这样,那就不行,它将无法正常工作-OpenFileDialog将在服务器而非客户端上打开.
您无法通过服务器上运行的代码在客户端上打开文件浏览器对话框.
When you talk about "Browse window" do you mean this is a web app? And this code is in the code behind? If so, then no, it won''t work - the OpenFileDialog will open on the server, not the client.
You cannot open a file browser dialog on the client via code running on the server.


这篇关于在带有C#代码的vb20008中单击打开后,如何从浏览窗口中打开内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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