如何在silverlight中创建文件上传按钮

发布于 2024-08-11 16:36:45 字数 55 浏览 4 评论 0原文

我知道这是一个愚蠢的问题,但我该如何创建一个呢?我需要它做的就是打开一个对话框并填充旁边的文本框

Stupid question I know but how do i create one? All i need it to do is open up a dialog box and populate the text box next to it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生生漫 2024-08-18 16:36:45

如果我理解正确的话,您只是询问将用户选择的文件名放入按钮旁边的 TextBox 控件中。您不是在询问文件的实际上传。如果这是正确的,那么我的答案是您可以这样做:

        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Multiselect = false;
        if (dlg.ShowDialog() == true)
        {
            yourTextBox.Text = dlg.File.Name;
            // Read stream of data from file, etc.
        } 

由于 Silverlight 中的安全限制,您无法显示通过 dlg.File.FullName 可用的完整路径。

If I understand correctly you are asking only about putting a user-selected filename into a TextBox control next to a button. You are NOT asking about the actual uploading of the file. If this is correct, then my answer is that you can do this:

        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Multiselect = false;
        if (dlg.ShowDialog() == true)
        {
            yourTextBox.Text = dlg.File.Name;
            // Read stream of data from file, etc.
        } 

You can't show the full path which would have been available via dlg.File.FullName due to security restrictions in Silverlight.

满栀 2024-08-18 16:36:45

您需要使用OpenFileDialog (silverlight 2.0)。有大量示例或者我是它的忠实粉丝视频演示 示例 2

You need to use the OpenFileDialog (silverlight 2.0). There are plenty examples kicking around or I am a big fan of Video Demo's example 2.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文