I have been wondering for quite some time whether t is possible to create a library which would act as a file provider in Windows.
For example if you try to open ftp://example.com/touch.txt file using standard Open file dialog, it (somehow magically) works. Is there a way how to implement my own provider for my own URI scheme?
Could Asynchronous Pluggable Protocol be a solution? I was not able to find a working code example on how to make it work.
To understand: I need this to work system-wide. This is nowise connected to internet browsers.
What if I need this File.Open("my://test.txt") to work?
Doing
File.ReadAllBytes("ftp://example.com/touch.txt");does not work, if you try it you get a exception likeThe reason it works when you do a OpenFileDialog is windows cheats with that and will download the file to a local temp folder first. It only does this for
ftp:andhttp:because OpenFileDialog is handled by the windows shell and the shell is what uses URI schemes.I believe the
Source Filterkey underHKCR\ftppoints to a registered COM object that handles the logic of doing that local copy.If you just want your application to be opened by going to a URL like steam does with it's
steam://rungameid/382110you just need to follow the instructions in this MSDN page.If you want your file to be "openable" via a shell like
http:orftp:does with the open file dialog you will need to write a COM object that acts as the "Source Filter", I do not know of any place to find documentation on that.Update: Reading more it does look like Asynchronous Pluggable Protocol like you mentioned is how you make those source filters. I have never tried to make one so I can't help you beyond that.