views:

59

answers:

3

I want to FTP 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?

+2  A: 

I don't believe so. FileInfo's constructor will only except a path, not a stream. I think your going to want to use the StreamReader class...

J.13.L
+1  A: 

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.

Matt Greer
+1  A: 

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.

weismat
A RAM Disk is also using a filesystem, what mrblah is searching for is writing a file on a volatile memory space.
Ucodia