473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

truncating / resizing stream

Should be simple, I open fileX,
then serialize my content back out ( with position set to
0 ). This works well as long as my new output is larger
than the old file input.

But when my output is smaller, it does not overwrite all
the data and so I get the new output plus the overhanging
piece of FileX.

What the quick way to let resize the stream to just my new
output ? THANKS

code to write out object like this:
stream.Position=0;
serializer.Serialize(stream,obj);
System.IO.StreamWriter Tout = new System.IO.StreamWriter
(stream);
stream.Position=0;
Tout.Close();
Nov 15 '05 #1
1 2608
Hello

you can either use stream.SetLength() method, or if it is a FileStream, open
with FileMode.Create to overrite any exiting file

Best Regards
Sherif

"andrewcw" <an************@boeing.com> wrote in message
news:3e****************************@phx.gbl...
Should be simple, I open fileX,
then serialize my content back out ( with position set to
0 ). This works well as long as my new output is larger
than the old file input.

But when my output is smaller, it does not overwrite all
the data and so I get the new output plus the overhanging
piece of FileX.

What the quick way to let resize the stream to just my new
output ? THANKS

code to write out object like this:
stream.Position=0;
serializer.Serialize(stream,obj);
System.IO.StreamWriter Tout = new System.IO.StreamWriter
(stream);
stream.Position=0;
Tout.Close();

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Clyde Ellul | last post by:
Hi there. I need to write a simple program that reads a GIF image from an input stream, resizes it, then writes it back to an output stream in the same format (GIF). (JPEG input/output is good...
4
by: qazmlp | last post by:
Can anybody comment(& suggest improvements) on the following implementation that is for truncating the character buffer contents to the desired length? Truncating char array void...
5
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hello, Can someone over here help me in truncating a float variable. I mean if PI=3.14159 ...How can I get to read the first two or first three decimal values with out rounding them. Any...
4
by: CodeRazor | last post by:
I'm unfamiliar with image manipulation using c#. How can i resize a jpg that currently exists in a file and save it resized as a new file. The examples i've found have been a bit misleading for...
1
by: Jitesh Sinha | last post by:
Hi, I am running Windows 2003/ IIS 6.0. I was stuck with rather a abnormal behaviour of System.Web.mail class. It was truncating the message body after 3,071 character. The code i was testing...
10
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full...
2
by: Czort | last post by:
I'm looking for a good ActiveX component for picture resizing (gif, jpg, png) from asp script. It should be able to load an image from stream (f.e. from recordset, binary data source etc.). For...
0
by: Oleg Ogurok | last post by:
Hi all, I'm having this problem. I have a 50x50 GIF image with a transparent background. I'm trying to resize it to 25x25 using GDI+ capabilities. With Windows Forms' Image control, the image...
3
by: rlrcstr | last post by:
Is it possible to truncate a MemroyStream to free up the space up to the current position? I wantes to be able to just keep dumping bytes into a stream and then read the stream as needed. After...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.