?
Solved

Create A file but not a physical file

Posted on 2004-04-07
3
Medium Priority
?
363 Views
Last Modified: 2010-04-15
Is there a way in C# to create a file, but never actually write it to disk. Just to create a small temporary file that would only be held as an object within the application. (I know this is a strange one) but it would make an application of mine much faster as I need to pass small files frequently, and it has to be files.
0
Comment
Question by:jj819430
3 Comments
 
LVL 6

Expert Comment

by:DaniPro
ID: 10773102
Yes, you can use the System.IO.MemoryStream class that stores the information in memory and not in a file.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 10773143
You can use the MemoryStream Class. Create instance of MemoryStream Class and fill it using Write* members. After this it can be used for reading using Read members.
For example, StreamReader class instance may be initialized from file name:
public StreamReader(
   string path
);
or stream:
public StreamReader(
   Stream stream
);

You can initialize StreamReaded from MemoryStream instance and read it exactly as file.
0
 
LVL 7

Author Comment

by:jj819430
ID: 10773426
Awesome. I won't get around to plugging this in for another 12 hours or so, but sounds like a reasonable answer so will give you the points.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question