473,387 Members | 3,750 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,387 software developers and data experts.

Is there any way for System.IO.StreamWriter Write method to write out part of the string to file. such as if the machine is shut down half way through? or does the file not actually exist until the entire write is completed successfully.

Is there any way for System.IO.StreamWriter Write method to write out part
of the string to file. such as if the machine is shut down half way through?
or does the file not actually exist until the entire write is completed
successfully.
Nov 17 '05 #1
2 3762
Hello

It's not .NET Framework issue. It depends on system you are running on. And
I guess, that you will have a broken file if you will restart your system in
the middle of file writing.

You can write your file to a temporary folder. And when the whole file will
be written you can move it to desired place. If system will be shutdown in
this moment, then you will have a broken file in temporary directory. But
you can always clean up it on systems startup. But, it will work only if
your temporary folder is resides on the same partition as your desired
location, so file moving can be done with one shot.


--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
"Daniel" <so*******************@yahoo.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
Is there any way for System.IO.StreamWriter Write method to write out part
of the string to file. such as if the machine is shut down half way through? or does the file not actually exist until the entire write is completed
successfully.

Nov 17 '05 #2
If the file is just text it will be fine. You can call flush after you write
each line which commits everything in the buffer. Obviously the file
wouldn't be complete and im pretty sure it will throw an exception if someone
were to shutdown the pc while this was running.

"Andrew Kirillov" wrote:
Hello

It's not .NET Framework issue. It depends on system you are running on. And
I guess, that you will have a broken file if you will restart your system in
the middle of file writing.

You can write your file to a temporary folder. And when the whole file will
be written you can move it to desired place. If system will be shutdown in
this moment, then you will have a broken file in temporary directory. But
you can always clean up it on systems startup. But, it will work only if
your temporary folder is resides on the same partition as your desired
location, so file moving can be done with one shot.


--
With best regards,
Andrew

http://www.codeproject.com/script/pr...asp?id=1181072
"Daniel" <so*******************@yahoo.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
Is there any way for System.IO.StreamWriter Write method to write out part
of the string to file. such as if the machine is shut down half way

through?
or does the file not actually exist until the entire write is completed
successfully.


Nov 17 '05 #3

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

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
12
by: R | last post by:
Hello everybody. I'm writing my own Content System in PHP5. I've written so far main classes for handling DB connections, XML, XForms and Sessions. But I've got problem with one thing - it's...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
1
by: Daniel | last post by:
Is there any way for System.IO.StreamWriter Write method to write out part of the string to file. such as if the machine is shut down half way through? or does the file not actually exist until the...
1
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...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
7
by: Mark Rae | last post by:
Hi, Has anyone successfully used the FTP stuff in the System.Net namespace against a VMS FTP server? I'm trying to do this at the moment and can't even get a directory listing, although there...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.