I can't find this in the documentation so I'm asking it here:
I assume that if I call Close() on a Stream based class that Flush() does
not need to be called before as it is implicitly called by Close()?
Thanks 3 22460
That is correct.
When you close the stream any remaining buffered content is written out at
that point, otherwise that data would be lost.
Chris.
"guy" wrote: I can't find this in the documentation so I'm asking it here:
I assume that if I call Close() on a Stream based class that Flush() does not need to be called before as it is implicitly called by Close()?
Thanks
guy <wi*********@ho tmail.com> wrote: I can't find this in the documentation so I'm asking it here:
I assume that if I call Close() on a Stream based class that Flush() does not need to be called before as it is implicitly called by Close()?
Yup.
For most streams (CryptoStream excepted due to a bug) you can just call
Dispose instead, which is much easier with a using statement:
using (Stream x = ...)
{
....
} // Dispose called automatically here
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi guy,
Calling System.IO.Strea m.Close on a Stream flushes any buffered data,
essentially calling System.IO.Strea m.Flush for you. System.IO.Strea m.Close
also releases operating system resources such as file handles, network
connections, or memory used for any internal buffering.
Nirosh.
"guy" <wi*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. I can't find this in the documentation so I'm asking it here:
I assume that if I call Close() on a Stream based class that Flush() does not need to be called before as it is implicitly called by Close()?
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tony |
last post by:
OK - let's get the IE bashing out of the way...
<space provided to bash IE>
</space>
On to the problem:
I have a query that I'm running on a test server that takes awhile to
|
by: Philipp |
last post by:
Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?
Thanks for answers.
Phil
|
by: Someonekicked |
last post by:
hi, i cant come to find a solution for a problem in my program, I made an
example of the problem;
in the example i made, the problem is if happy.dat does not exist, so
(!inData) will be true, and "here is the message" is sent to output to
happy.dat, and if u run the program, you will see that "here is the message"
is sent to happy.dat after the program ends, not be4 cout << "check"; i want
that "here is the message" be sent to file be4...
|
by: ruhunu Gamarala |
last post by:
Hi,
I get the following exception periodically. does anybody what is the reason for it to throw this exception?
I really appriciate if anyone can help me on this.
thanks,
Chinthaka
at org.postgresql.PG_Stream.flush(PG_Stream.java:356)
at org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:159)
at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:70)
|
by: Daniel |
last post by:
System.IO.StreamWriter Close or Flush method to shut down the computer in
such a way that just part of the file is written? or an empty file is
written? Also if the Close or Flush is to a streamwriter writing to a
network share, is it possible for the network to go down in such a way that
the tartet file is only partialy written? or are there some kind of check
sums to prevent this.
| |
by: Tom |
last post by:
Do I really need to flush a streamwriter? It appears to work either way.
Dim sw As StreamWriter
Dim strFullPath As String = "C:\Temp\Test.txt"
If File.Exists(strFullPath) Then
sw = File.AppendText(strFullPath)
Else
sw = File.CreateText(strFullPath)
End If
|
by: r0main |
last post by:
Hi,
I'm facing an issue to send data throught the HttpWebRequest processing,
I'm using the Method POST with a multipart form/data.
While writing a file, my application is buffering the whole size of the
file, and it sends it... That's pretty sucks with large file.
while ((bytesWritten = fileStream.Read(b, 0, 4096)) 0)
{
|
by: tegdim |
last post by:
Hello,
I'm trying to send a string to a subprocesses' output stream in my java program. I'm writing the data to the stream and then trying to flush the stream.
This, however , isn't actually sending anything to the subprocess (a python program) and the data only actually gets sent to the outputstream when I close the stream. I'm wanting to keep sending data to the subprocess so the writing and flushing is in a loop, but because I have to...
|
by: =?Utf-8?B?cmF1bGF2aQ==?= |
last post by:
(a little more info)
after flushing the line (instead of closing streamwirter)
it takes some x time to flush the line
so, when I read from the file I cannot find the last written line.
if I close the streamwriter it does find the line always.
but , my next write fails "Cannot write to a closed TextWriter"
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |