Does WPF have a control for browsing the local file system? - c#

I would like to add a control to my app where the user can browse his local file system and select a directory. I would prefer to host this control on my main app window, and not do this via a pop-up dialog.

There isn't one built in.
You can either use the WinForms file/folder browser, search Code Project or similar site for someone else's implementation or write your own.
I've found one on Ookii Dialogs that includes some other standard dialogs.

If you want to host the controls on your own form, use controls from Shell MegaPack.WPF

Related

How to get opened FileDialog references in WPF/Winforms/C#?

I'm trying to build an app that synchronizes a FileDialog to a specific path. I'm not opening the FileDialog myself, I need access to "all the currently opened FileDialogs", get a reference to the one I need and then change the currentworkingdirectory. Is there an API to get all opened filedialogs in Windows?
If you need a better explanation, here's a video of the feature I'm trying to implement: https://www.youtube.com/watch?v=9T9-OtRVeUw
Thanks!
“Is there an API to get all opened filedialogs in Windows?” No, because there is not just one in-box file dialog, and many applications use custom implementations (e.g.: Java, qt, Office 2016+).
The video you posted looks like they are hooking or subclassing the most common dialog and (probably) using automation (either COM or window messages) to set the folder.
Separately, I don’t quite understand the desired function. If you have the explorer window open, drag or copy/paste the desired file into the app or file dialog. No need for nonstandard hacks.

Is there any way to combine a folder picker and a file picker in UWP?

I want the user to be able to select both files and folder in a picker dialog. Is it achievable in UWP?
The only way around this that I can think of is to create a flyout menu for the browse button that allows you to choose a folder or file item to pick then opens the corresponding dialog. But I want the user to decide after the dialog is shown or even choose both files and folders at the same time.
Should I just include the old OpenFileDialog? It seems like the wrong way to go about this.
I want the user to be able to select both files and folder in a picker dialog. Is it achievable in UWP?
As far as I know, it is not possible now in traditional UWP app. When your call the file/folder picker in your app, it calls a single, unified interface to let user pick files/folder from the files system or from other apps. As we know, UWP apps work in sandbox(app container), file/folder pickers break this container by using brokers, this is handled by system.
But it's just in traditional UWP app, there is method now to use Win32 APIs in UWP app if your app won't be published to Store. If you are interested in this method, you can refer to Brokered Windows Runtime Components for side-loaded Windows Store apps.
Our suggestion is that you may submit a request to add this new features for developing through the Windows Feedback tool.

How to create an Explorer-like folder browser control?

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default.
Ideally, I would like its contents to be exactly the same as in Explorer. For example, on Windows 7, it should show the Favorites and Libraries pseudo-folders. Of course, I do not want to code specifically for each version of Windows if I can help it.
I have browsed around, and there are some examples of such controls, but they are all hand-rolled and therefore won't work 100% the same as the one in Explorer.
Is there any way I can simply reuse the Explorer control instead? Or, if not, to get access to a tree of the items that it would show?
Microsoft provides a walkthrough for creating a Windows Explorer style interface in C#.
There are also several examples on Code Project and other sites. Immediate examples are Explorer Tree, My Explorer, File Browser and Advanced File Explorer but there are others. Explorer Tree seems to look the best from the brief glance I took.
I used the search term windows explorer tree view C# in Google to find these links.
It's not as easy as it seems to implement a control like that. Explorer works with shell items, not filesystem items (ex: the control panel, the printers folder, and so on). If you need to implement it i suggest to have a look at the Windows shell functions at http://msdn.microsoft.com/en-us/library/bb776426(VS.85).aspx.
Take a look at Shell MegaPack control set. It provides Windows Explorer like folder/file browsing with most of the features and functionality like context menus, renaming, drag-drop, icons, overlay icons, thumbnails, etc

Implementing Folder Explorer with webbrowser C# winform

I' trying to use webbrowser to create a folder explorer and I have few problems that I could not find any answer on the web... so I’ll appreciate your answers:
Can someone please explain how can I create the Up button (going to parent folder)?
How can I the explorer bar (on the left) to favorites or search as in windows explorer?
How can I implement the undo functionality (undelete files and folders)
What I would do intercept calls to a url and inject the data from your application. That way you can write HTML and display whatever functionality you want.
This Code Project WebBrowser Control might be useful too. I wouldn't be surprised if it allows you to handle the button click events on the navigation bar.

Embed a File Chooser in a UserControl / Form

I've inherited a desktop application which has a custom .NET file chooser that is embedded in a control, but it has some issues.
I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog).
However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog.
Is there a control I'm missing, or does MS only provide the popup dialog out of the box?
The .Net control is a thin wrapper for the common dialog built into windows, and that is a dialog. So there is no way to embed it as though it were a control.
Depending on your needs, you COULD abuse the web browser control to show local files and folders. It won't match all the functionality of the OpenFileDialog, but it could work.
Here's one that I remembered from way-back. The Shell Mega-Pack. It has ActiveX and .NET versions. It looks promising.
Alternatively, if you want to build your own, you could start here on CodeProject: A Windows Explorer in a User Control. That looks like a good start. Here's another one: An All VB.NET Explorer Tree Control with ImageList Management.

Categories

Resources