1

Firstly I don't completely have a clue if the so-called Platform.VirtualFileSystem can do this. What I want for a virtual file system is somehow create a virtual file from a Stream (that I've already had). The system (OS) will be able to access that virtual file as if it was a real file (transparently).

After browsing the classes hierarchy of the Platform.VirtualFileSystem, I could not completely find anything related to what I want. It looks just like that I can link an actual system file to the virtual file but here I don't even have the actual system file, what I have is just a Stream.

Does anyone have a simple example to illustrate this? As I said before, I did not even know if that library is what can help me. So if you have another alternative ones that could solve my problem, please suggest.

halfer
  • 19,824
  • 17
  • 99
  • 186
Hopeless
  • 4,397
  • 5
  • 37
  • 64
  • 2
    I'll say that you are looking at the wrong tool. The `P.VFS` is an abstraction of various fs for the program that links to P.VFS. It doesn't seem to export this abstraction to other programs. What you need is a full file system. But note that a full file system is a full disk. You don't create a file, you create a virtual disk with a file. – xanatos Jun 20 '18 at 11:34

1 Answers1

1

I'll say that you are looking at the wrong tool. The Platform.VirtualFileSystem is an abstraction of various fs for the program that links to Platform.VirtualFileSystem,. It doesn't seem to export this abstraction to other programs.

What you need is a full file system. But note that a full file system is a full disk. You don't create a file, you create a virtual disk with a file. See for example dokan.

One of the things it can do is:

Data as file

Easily mount any kind of data as a virtual file and access it transparently from all your Windows applications. It can literally be anything: files from other locations, stored locally or remotely in the cloud... Creativity will be your limit.

Note that using Dokan seems to be quite complex. Normal persons don't go around writing file systems. For sure it is at least a little over my level. You can probably begin with the example read-only file system for the Registry and trim from there.

Community
  • 1
  • 1
xanatos
  • 109,618
  • 12
  • 197
  • 280
  • this `Dokan` seems to create a separate file system (which requires a different root)? Can it create a virtual file with a specified **relative path** to some actual file system root? Such as my app's path. The original issue I'm trying to sort out is create a virtual file *relative to the app's path* with a dynamic content (of Stream) prepared by my app. (so actually I don't want to use Temp file instead). – Hopeless Jun 20 '18 at 11:50
  • @Hopeless I wrote it quite clearly: *What you need is a full file system. But note that a full file system is a full disk. You don't create a file, you create a virtual disk with a file*. You could then try simlinking the file on vfs to the target folder you want (not sure it would work) – xanatos Jun 20 '18 at 11:54
  • I think at the OS level, the input is just the "file path" (or the URI), what behind is not important. So that's why it's called "virtual". I've just skimmed the examples in github and looks like it mounts the file to a separate drive (I call it root). Anyway I can treat it as temp file and it still works as what I want (I mean *relative path* is good but not required). – Hopeless Jun 20 '18 at 11:58
  • @Hopeless What you are looking for is called ["reparse point"](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503(v=vs.85).aspx) in Windows, but there is no documentation around about how to implement it, and even if there was documentation, it would be for C not C#. – xanatos Jun 20 '18 at 12:16
  • I've just tried the Dokan (binding version for .NET) and looks like it's not easy to make it work. It involves some pre-install (into the client), so I think it's not appropriate for my requirement (do not install anything on the client). What you mentioned about *reparse point* is really not easy. I've also tried the so-called `Pismo File Mount` but it failed for no reason (looks like it also requires to pre-install something into the client first) – Hopeless Jun 21 '18 at 02:19
  • @Hopeless Even reparse points require an install. You need a Mini Filter Driver to handle the reparse point. A reparse point in the end is a special file that signals the NTFS that it must call your Mini Filter Driver that will do whatever it wants. – xanatos Jun 21 '18 at 06:50