I am currently using FolderBrowserDialog to select a folder in my .NET solution. However, this dialog does not allow me to select SharePoint folders, just local or network folders.
I would like to use something similar to SaveFileDialog or OpenFileDialog, because they allow browsing SharePoint folders. However, these options seem to require that you specify or select a specific file, rather than a folder.
Is there a way to use create a folder picker similar to SaveFileDialog or OpenFileDialog? Ideas in VB.NET or C# are welcome.
UPDATE:
As a workaround, I am now using the folder picker from an Office application, like this:
app.FileDialog(Office.MsoFileDialogType.msoFileDialogFolderPicker)
where app can be the Excel, PowerPoint, Word, etc. application object. I would still prefer not to have to reference an Office app to pull this off, but it's the only option I have found so far. I did not submit this as the answer because I am hoping for a real solution, rather than a workaround.
If OpenFileDialog and SaveFileDialog works for you you can select a file and then use the command
C#
Path.GetDirectoryName(path_to_file);
or in VB.net
Path.GetDirectoryName(path_to_file)
I don't know if it fill your needs... It depends where you need this code and if the folder starts empty or not, as you know if the folder starts empty this method will not work
This if you decide to stop using
Office.MsoFileDialogType
Related
I am currently building an application that will need to use all of the Control Panel's shortcuts which can be found in "shell:::{ED7BA470-8E54-465E-825C-99712043E01C}" aka GodMode folder.
However, when I try to access the folder through code, I get no result. This also happens when I try to enumerate the files using the command prompt (using 'dir').
Any help is appreciated.
Thanks
The God Mode is implemented in the Windows Explorer Shell. If you look at it at the file system level it's just an ordinary folder with a peculiar name. That's why you won't see anything special in it when reading it as a directory in code. If you look at it with the command prompt it's the same - just a plain empty folder with a peculiar name.
You won't be able to access the shortcuts through the file system API, so you have to look for an API that exposes the control panel contents instead.
I have an app and I am thinking that a WPF XBAP app would be best suited for this. However, I am not aware of the limitations that it comes with. So, before choosing this tool I need to be aware of it.
Basically I want to read any folder inside the OS and get listing of files inside that folder. Is this possible using WPF XBAP?
OpenFileDialog is just a media that makes selection & reading easier. You can read any folder as long as you know path & have permission to read the folder.
so what I'm trying to do is open a file (well, actually two folders, but I figure I'll start with a single file for now) using a third party comparison tool called UltraCompare. I'm working in a C# website project in Visual Studio 2010 (Express edition). I've seen how to open a file using a different program, here: Open a file with Notepad in C#.
Problem is, this only lets you open it using the default program for that file type. But I want to open it in a specified program. For example, a text file should open in UltraCompare, not notepad. Here's the code which does this:
string textBoxContents1 = TextBox1.Text;
Process.Start(textBoxContents1);
The textbox on the webform accepts a string, in which the user types the file's full path (not the most user-friendly design I know, but I'm not sure how to allow them to browse for a folder using a GUI interface in asp.NET). The file is then passed into the Process.Start() method, which opens it using the default program for that file type.
Is there any way to modify this to make it open using UltraCompare??
You can specify the program you want to open the file in:
Process.Start("yourprogram.exe", textBoxContents1);
Update
To open two files in Ultracompare, you'd probably do something like that:
Process.Start("yourprogram.exe", "file1.txt file2.txt");
Keep in mind that the second parameter of Process.Start method are the arguments passed to the program.
I said this is probably going to work because I assumed to be very likely that Ultracompare expects 2 arguments, but this might not be the case.
Quick question: Are you trying to do this for the client machine? Hope not
And I guess it looks into the PATH variable for finding your exe
In my application the user can select reference to file, for example a image file. I would like to make button with a arrow that opens a list with the programs installed on the system witch can open this file type.
I know that I can get the program names from the registry "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts", but how can I filter the entries out that have no meaning - "DllHost.exe, miaui.exe, etc."
And how can I open the file with program that the user choose?
# Lars Tech If I look in registry "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" and then "OpenWithList" for the extension ".jpg" I see more entries that if if rigt click on jpg file and choose Open With ( see my first images) and I only want those.
And yes there is program's entries that I properly self have added, but that have no meaning to a jpg file. And Windows can filter them out so will I.
I think you can use this article to validate and find out which of them are applicable and valid in your application
If running on Vista or better, you can use
'SHOpenWithDialog'
http://msdn.microsoft.com/en-us/library/bb762234(v=vs.85).aspx
- it's quite straightforward...
Jens
Is it possible to list all the applications on a machine that can open a specific file type, using only the files extension? for example if I have a text file (.txt), I want a list of all applications that can open .txt files.
Check out the HKEY_CLASSES_ROOT hive in your registry. It's all in there.
There is no master list of every application that can open a specific file that I am aware of.
I am assuming you are talking about Windows machines...
You can only go so far as listing the applications that are registered has to able of handling a specific file extension (the same applications that show up when you right click and select "Open With"). This is somewhere in the Windows Registry.
I would suggest you to check on the microsoft documentation, or open your registry and start searching for known extensions.