Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create A file but not a physical file

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System.Speech 2 32
send messages to whatsapp programatically 2 60
C# winforms programmitically move panels 6 42
Adding items to a C# list incrementally 5 28
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

765 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