is it possible to create an in-memory file and access it with FileInfo?
I want to FT开发者_如何学GoP a file, and I am using the FileInfo class for certain things.
Would it be possible to create an in-memory file and initialize FileInfo with it?
How could I then write the file to disk if I wanted to afterwards?
I don't believe so. FileInfo's constructor will only expect a path, not a stream. I think your going to want to use the StreamReader class...
No, FileInfo only works against things on the filesystem. Why not create the file in a temp directory, then move it to its final destination as needed? Path.GetTempFileName
and Path.GetTempPath
may be of use.
You could work with a RAM disk if you want to have the benefits - look for instance at this article at superuser.com.
I am personally using Superdisk because I use an app which writes exentsive logs and I gained a performance by using it, but if you have control I would think twice about adding this external dependency.
精彩评论