C# Open/SaveFileDialog with a different file syste

2019-08-27 12:38发布

问题:

I'd like the standard windows open and save file dialogs, however, the particular application I am using it for is a remote file system (basically, I'd love to somehow just provide a IFileSystem interface to SaveFileDialog and have it magically change the files it sees by me providing them). Does anyone know of a complete implementation of those dialogs that supports this functionality? Is there any way to do it with the standard C#/windows dialogs?

If not, I will be implementing the dialog myself. I would still love any resources to implementations of these dialogs, even if they don't support this functionality, just so I could rip them apart and add that functionality myself.

Thanks!

回答1:

The only choice is to implement your own Shell Namespace Extension. It may be registered as a "My Computer" child so it looks like another drive. Beware: this is a tedious work and due to .NET framework limitation (<4.0), it has to be written in C/C++.

Here is the example.



回答2:

These classes are very thin wrappers around calls to native Windows shell api functions. GetOpenFileName() for XP and earlier, the IFileOpenDialog COM interface for Vista and up. If you cannot see the file system in Explorer then those wrappers are not going to be useful at all.