Solved

Create A file but not a physical file

Posted on 2004-04-07
3
350 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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now