问题标签 [fileopendialog]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
160 浏览

c# - WPF中取消加载文件操作失败

我很抱歉这个奇怪的标题。我正在开发一个 WPF 应用程序,我应该通过单击按钮从系统加载文本文件并读取文件的内容并在文本框中显示文本文件的内容。

我做了以下事情:

XAMl:

视图模型类:

文件阅读器类:

我在这里面临的问题是,当我单击加载按钮时,它会打开一个文件对话框,但它会显示所有文件,而不仅仅是显示 .Txt 文件。如何确保只有 .txt 文件可见?

其次,当我单击按钮时,会弹出对话框,如果单击取消按钮,应用程序会崩溃并显示“空路径名不合法”。这是指向using (StreamReader sr = new StreamReader(path))

我怎样才能清除这些问题?:)

0 投票
1 回答
175 浏览

c# - 无法通过 FileOpenDialog 在 WPF 中加载脚本文件

我正在开发一个 WPF 应用程序,我刚刚遇到了加载脚本文件(.xml)操作,我应该从系统加载它,从组合框中获取文件并调用加载方法。

xml:

视图模型:

这将打开一个文件对话框,让我选择一个 .xml 文件。在这里,当对话框打开时,它不会显示 CurrentWorkingDirectory。怎么可能达到???因此,当我单击打开并在 ScriptPath statemnt 附近放置一个断点时选择后,它会在我的组合框中显示文件的路径。

我还想获取这个文件并将其存储在 FILE 类型中,从而调用 LoadFile 方法。我在 C++ 中这样做如下:

在 WPf 我确实喜欢:

我在 C++ 代码中将 FILE 作为参数传递,在这里我传递一个字符串。读取 xml 文件时会产生任何问题吗?

0 投票
2 回答
771 浏览

c++ - Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?

Vista introduced an interface: IFileDialog::SetFilter, which allows me to setup a filter that will be called for every potential filename to see if it should be shown to the user.

Microsoft removed that in Windows 7, and didn't support it in XP.

I am trying to customize the our Open file dialog so that I can control which files are displayed to the end user. These files are marked internally with a product-code - there isn't anything in the filename itself to filter on (hence file extension filters are not useful here -= I need to actually interrogate each one to see if it is within the extra filter parameters that our users specified).

I would guess that Microsoft removed the SetFilter interface because too often it was too slow. I can imagine all sorts of similar ideas to this one which don't scale well for networks and cloud storage and what have you.

However, I need to know if there is an alternative interface that accomplishes the same goal, or if I really am restricted to only looking at the file extension for filtering purposes in my File dialogs?


Follow-up:
After looking further into CDN_INCLUDEITEM, which requires the pre-vista version of OPENFILENAME, I have found that this is the most useless API imaginable. It only filters NON-filesystem objects. In other words, you can't use it to filter files. Or folders. The very things one would filter 99.99% of the time for a file open or save dialog. Unbelievable!

There is a very old article by Paul DiLascia which offers the technique of removing each offending filename from the list view control each time the list view is updated.

However, I know from bitter experience that the list view can update over time. If you're looking at a large folder (many items) or the connection is a bit slow (heavily loaded server and/or large number of files), then the files are added to the dialog piecemeal. So one would have to filter out offending filenames repeatedly.

In fact, our current customized file open dialog uses a timer to look at the view's list of filenames periodically to see if any files of a given pattern exist, in order to enable another control. Otherwise it's possible to check for the existence of these files, find none, but a moment later the view updates to have more filenames, and no events are sent to your dialog to indicate that the view has been changed. In fact, my experience with having to write and maintain code for the common controls file dialogs over the years has been that Microsoft is not very cluefull when it comes to how to write such a thing. Events are incomplete, sent at not-useful times, repeated when not necessary, and whole classes of useful notifications don't exist.

Sadly, I think I might have to give up oh this idea. Unless someone has a thought as to how I might be able to keep up with the view spontaneously changing while the user is trying to interact with it (i.e. it would be awkward to go deleting out entries from the list view and changing the user's visual position, or highlighted files, or scroll position, etc.)

0 投票
1 回答
262 浏览

vb.net - 在 OpenDialog 中预览图像

在 Visual Basic.NET 中,通过 OpenFileDialog 控件浏览文件时,是否可以在 OpenDialog 中选择图像时显示图像预览?

0 投票
3 回答
1390 浏览

c# - windows phone 中的文件打开对话框

我正在开发 windows phone 应用程序,我需要应用程序中的文本文件导入工具。现在我需要像在 Windows 桌面应用程序或 html 文件控件中一样打开文件资源管理器。

我用谷歌搜索了所有可能的方法,但没有找到解决方案。

0 投票
1 回答
101 浏览

c# - 如何为 bmp.screenshotsave 添加可选目录

我需要帮助。我想实现在保存屏幕截图之前选择文件夹的功能。这是我创建的工作代码:

它是自动截图器,它增加了一些截图。但是现在的文件夹是不变的。我想在捕获自​​动屏幕截图之前创建文件夹选择。我用这个:

我不知道为什么它不起作用。

0 投票
1 回答
231 浏览

delphi - 在创建主窗体之前使 Vista+ 文件对话框工作

在一个小应用程序中,我想在创建主窗体之前显示一个打开的文件对话框。我在 *.dpr 中这样做:

当我使用以下初始化过程时:

Windows 7 下没有显示对话框。我可以通过将 UseLatestCommonDialogs 设置为 False 来解决此问题,但我想避免这种情况。将 Init 过程更改为

作品。但是我不确定我是否正确使用了 CoInitialize/CoUninitialize,例如:

  • 我这么早就调用 CoUninitialize 会搞砸一些事情吗?
  • 必须“知道” TOpenDialog 内部(有时)使用 COM 的事实就像我宁愿避免的泄漏抽象。

编辑:我找到了一个更好的方法:如果我添加ComObj到 dpr 的uses子句中,我可以省略CoInitialize/CoUninitialize调用。当然,泄漏的抽象问题仍然存在。

0 投票
1 回答
129 浏览

file - 如何获取要在我的 PowerShell 脚本中使用的文件的位置?

我一直试图解决这个问题,但没有运气,我想弹出一个文件打开对话框,我已经能够使用我在网上找到的功能来完成,然后使用文件位置进一步向下我的脚本中的行,但我无法弄清楚。

这是功能

我是 powershell 的新手,所以我不确定函数是如何工作的。

0 投票
2 回答
1022 浏览

c# - 使用 Javascript 打开本地文件

有没有一种方法可以使用 javascript 在本地计算机中打开文件,无论它是 jpg、doc 还是 pdf?

我尝试了在互联网上找到的所有代码,运行时出现“拒绝访问”或“拒绝权限”错误。我认为这也是一个安全问题。

0 投票
1 回答
37 浏览

c# - openfinedialog c#中的多个选定文件

我想使用openfiledialog选择多个excel文件,每个excell的输出必须存储在数据表中,我必须收集数据集中的数据表才能在我的应用程序中用作gridview的数据源,我使用windows desktop 4.5 ,谢谢