Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

cutom stream

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ajit - 29 Jun 2007 16:24 GMT
I am planning to implement custom stream which will be memory stram until
certain point and then become file stream if it exceed cetain size any ideas
would be very helpful
Peter Duniho - 29 Jun 2007 17:16 GMT
> I am planning to implement custom stream which will be memory stram until
> certain point and then become file stream if it exceed cetain size any  
> ideas would be very helpful

I would simply inherit Stream and implement the required methods,  
including a field that holds a reference to an internal Stream to which  
you forward those methods, which is set to a MemoryStream until some point  
in time that you decide (for example, the MemoryStream becomes too large),  
at which point you copy the MemoryStream to a new FileStream, and then  
replace your internal Stream reference with the new FileStream.

That said, you should think carefully as to whether you really want to do  
this.  If you have a specific design requirement that the data wind up on  
the disk in a file accessible to the user once it gets too large, then  
perhaps your goal makes sense.  But if you are simply trying to do some  
sort of caching or something, in a way hidden to the user, you are likely  
to perform _worse_ trying to implement it yourself rather than just  
letting the Windows memory manager deal with it for you.

In other words, just use a MemoryStream, and let Windows decide what is  
"too large" as well as let Windows copy your data to the disk as necessary  
(via the normal virtual memory management strategies).

Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.