473,778 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Seri alize(stream,ob j);
System.IO.Strea mWriter Tout = new System.IO.Strea mWriter
(stream);
stream.Position =0;
Tout.Close();
Nov 15 '05 #1
1 2632
Hello

you can either use stream.SetLengt h() 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.Seri alize(stream,ob j);
System.IO.Strea mWriter Tout = new System.IO.Strea mWriter
(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
11257
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 too, but GIF is preferrable). JAI can do this sort of but can't write to GIF format. Also, it looks too complicated for what I need; I'm a bit in a hurry... Is there a simple way of doing what I want? Is there a free,
4
21984
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 truncateCharArray(int maxLength , char * buffer ) { if ((0 == buffer) || !(0 < maxLength)) return; if (maxLength < strlen(buffer))
5
5432
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 suggestions are appreciated. I am BEGINNER TO C PROGRAAMING. Thanks
4
4248
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 my particular requirements.
1
2521
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 was: Import Namespace="System.Web.Mail" Dim aa as new StringBuilder(600010) Dim i as Integer
10
4163
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 resolution (ie. large). I have a database that contains references to the pictures. Currently I have to resize the jpgs manually, and then point the ImageUrl property at that jpg using databinding. This works fine. I would like to avoid the resizing step...
2
1044
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 free or cheap - for commercial project. -- Thanks Czort
0
1281
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 shows fine. However, when I try to stream the image into a browser in a ASP.NET application, the background that's supposed to be transparent looks grayish. Here's my codebehind:
3
5082
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 the read, free up the portion of the stream I read, esentially making the first unread byte the first byte in the stream. Thanks. Jerry
0
10127
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10068
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7474
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.