I have a WPF application which maintains a set of virtual 'folders' (organizational concept), and I'd like to hook into something like the Folder Browse Dialog to select a folder (as a parent to some other kind of operation).
These are NOT denizens of the filesystem - what I need to do is be able to programmatically tell the dialog that at parent folder F, folders C1, C2, and C3 exist. I'd like the user to be able to browse and then select a folder - and then get the final selection information returned to me (what was the parent, which child was selected).
In other words, I want something that LOOKS like the Browse Folder Dialog - but I fill it with my own pretend set of folders and subfolders; and at the end I can get out the folder they actually chose.
Any way to do this in WPF?
Maybe you could restrict the folder opened AND populate with fake folders. Sounds unlikely to me though.
It will probably turn out more productive to create your own control with a treeview and your fake folders. And pop that up.
If you copy the layout of a file open dialog box as close as possible, most user will believe it is one and the usability will be decent.
Related
I am building an add-in which requires selection of multiple outlook folders. For that purpose I created selection dialog that lists folders and allows user to select one or more by checking the check boxes next to tree view items.
I was hoping that somehow I could read/get the outlook folder icons from my add in code which is written in C# (any solution that works with outlook object model would do).
I was trying hard around MAPIFolder.GetCustomIcon but it returns null for all folders and when you read the documentation it is clear that it is not meant for this i.e. it returns value only if folder has custom icon and if it is not any of default folders.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getcustomicon%28v=office.14%29.aspx
Thanks for reading.
You'll have to use an icon editing tool (like Axialis Icon Workshop) that can extract icon and image resources from related Outlook .dll and .exe files. It's a real mess to figure out what icon is where there as they exist in small and large quantities in very many different files.
I'm making a documentation program and I built a search engine with text boxes,combo boxes,and check list boxes. I haven't written a code that actually does the searching, there are just buttons and the components.
Anyways the files I want to access are in one folder in the C drive and in that folder there are many other folders and subfolders. I want the user to either type in the desired name of the folder,or select from a combo box.Normally we can open a folder with this code:
Process.Start(#"C:\Users\melek\Desktop\svn");
I don't want to write Users\melek etc each time in code. I need a code that grabs the users selected folder or file name(using combo boxes and text boxes) and find the folder and display it in windows form.
Is it possible to convert the selection from the text box or combo box to string and use the Process.Start command?
We solved this problem like this:
we obtained a path and used this code:
listBox1.DataSource = System.IO.Directory.GetFileSystemEntries(path1);
What you're trying to do requires several steps, so let's discuss them in turn.
First you need to get a path from the user so your program knows where to search . A FolderBrowserDialog attached to a button provides this. No need to hard code any paths since you can fetch the path string from this dialog.
Next you can use the Path, Directory and File classes to perform operations such as, fetching a list of all subfolders from a path, extracting paths of paths as strings for additional searching, and checking properties or flags on files and folders in case you decide to support more advanced search options.
I would suggest understanding these core file system classes more if you're going to be doing any amount of development that interacts with the file system. They are your bread and butter. I've linked to the MSDN documentation for each, for your convenience.
I have a Windows Form application and I use a custom control that allows users to select and save image. However I need to insert some restrictions. The easy one was to select only jpg files but now I need to restrict the users to be able to see and select only jpg images with certain pattern in the name and if possible (I think I've seen this implemented in other windows applications) I want this pattern to stay in the File Name field and the user to not be able to delete it.
what I have done till now :
I have the restriction set:
fileNameFilter = "All files (*.jpg)|" + ImageNameFilter + "*.jpg";
openFileDialog1.Filter = fileNameFilter;
I can show the user what pattern he needs to look for:
openFileDialog1.FileName = fileNameFilter;
However there are two things that I still can't accomplish. Here is a print screen to make it clear:
First - the pattern is shown but I can delete it when it's made like this and I want if it's possible the File name field to be Read only or in other words the user should not be able to delete what I have put there.
Second - this is the list with previously opened files even though the file don't match the name restrictions/filters the user is still able to select form the list and save that file. I need, again if possible either to clean this list when the File Dialog is opened or somehow to stop the user from being able to save this file but i think the second will require too much extra business logic so I prefer just to clean the list.
Trying to control rigidly what's shown in a file dialog through a filter or a file name pattern is not going to work. The user can always type their own pattern into the file name edit box.
What you need to do is use the file dialog's facilities for controlling what objects are displayed. Unfortunately the C# wrapper doesn't expose this functionality that is offered by the underlying Win32 controls.
If you need to support XP, then you need to listen for the CDN_INCLUDEITEM notification. This is sent for each item in the folder. You therefore get the opportunity to either allow or deny the inclusion of each item.
For the dialogs used in Vista and later it's different. These dialogs use IFileDialog. You need to call the SetFilter method to add a filter. That filter is your implementation of IShellItemFilter which again controls inclusion using the IncludeItem method.
It's going to be a bit messy to make all this happen from C#, but this is the correct way to do what you ask. Once you do this, there's no need to even think about trying to make the file name edit box read-only. Because the dialog will only offer up the items that you have allowed to be included.
No.
Two solutions: check the filename after Open-click (which you should do anyway), or create your own control that displays files that do match your filename pattern.
I C# I need a dialog box that will allow a user to select certain folders. Ideally I would like a dialog box that will show only the contact folders and allow the user to select a certain subset of them.
See MSDN:
Outlook.Folder folder = Application.Session.PickFolder();
You also could get all folder recursively and build your own form to pick subset (and use any filtration you want and add ability to add new one).
In my application I have two places where the user needs to select a file. In both cases, the files are in different directories, but they are generally the same between runs.
The OpenFileDialog appears to be defaulting to the last directory used, but this is useless to me since it is almost always the wrong folder, and I end up alternating between the two folders. What I would like is to somehow have the first dialog remember the path that was used the last time it was opened, and the second to remember its own path as well.
Example: Path A is C:\foo\bar\something\x.dll, Path B is C:\foo\baz\whatever\y.xml
Dialog a opens and I select A, then later dialog b opens(defaulted to A) and I have to navigate back and up to B.
When I open the app again dialog a opens (defaulted to B) and I have to navigate back up to A again.
I would like to avoid all of this extra navigation by remembering the paths separately. Is there a good way to do that?
When you open each dialog, just set the dialog's InitialDirectory property to the folder that was last used for that dialog.
Granted, this will require saving the directory for each dialog, but it will provide the behavior you are looking to achieve.