Solved

Create A file but not a physical file

Posted on 2004-04-07
3
351 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a complete list of ASP.NET page load events 3 28
C# Json POSt to Rest API 4 37
Error in JQuery 5 39
Device Location 4 19
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…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 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

18 Experts available now in Live!

Get 1:1 Help Now