如何从Web浏览器(C#)获取文件名? [英] How do I get a file name from a web browser (C#)?

查看:123
本文介绍了如何从Web浏览器(C#)获取文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Web浏览器组件作为文件资源管理器。我要做的是将所选文件的文件名存储在变量中。示例:如果用户导航到C:\ SomeFolder并从该文件夹中选择File.txt,我希望能够将File.txt存储到变量中以供将来使用(例如,删除所述文件)。我需要该变量根据用户点击的任何文件动态更改。任何帮助将不胜感激。



我尝试过:



我整个上午一直在搜索谷歌,但到目前为止,我还没有找到解决方案。我查看了GetFileName,但我不确定如何通过鼠标点击来完成这项工作。

I am using the Web Browser component to function as a file explorer. What I am looking to do is store the file name of the selected file(s) in a variable. Example: If a user navigates to C:\SomeFolder and selects File.txt from that folder, I want to be able to store "File.txt" to a variable for future use (say, deleting said file). I need that variable to change on the fly based on whatever file the user clicks on. Any help would be greatly appreciated.

What I have tried:

I have been searching the Googles all morning, but, so far, I have not found a solution. I have looked into GetFileName, but I am not sure how to make that work on mouse clicks.

推荐答案

Quote:

这个应用程序的目的不是打开文件,而是传输它们(想想WinSCP)。由于安全限制,我无法在服务器上安装WinSCP。但是,由于客户端已请求类似的东西(并锁定到特定位置),因此我创建了自己的版本。我唯一征服的是选择一个文件,然后点击删除按钮。

The point of this application is not to open files, but to transfer them (think WinSCP). Due to security constraints, I cannot install WinSCP on the server. However, since the client has requested something similar (and locked down to specific location) I have created my own version. The only thing I have conquered is selecting a file and then clicking a delete button.





OpenFileDialog不会打开任何内容 - 它会选择一个文件,将信息返回给您的应用程序,以便您可以决定如何处理它。



使用WebBrowser作为文件选择器是......嗯...使用大锤破解坚果。



The OpenFileDialog doesn't open anything - it selects a file and returns the info to your app so you can decide what to do with it.

Using a WebBrowser as a file selector is ... um ... using a sledgehammer to crack a nut.


这篇关于如何从Web浏览器(C#)获取文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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