473,738 Members | 8,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there any way for System.IO.Strea mWriter 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.Strea mWriter 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 3801
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.c om> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
Is there any way for System.IO.Strea mWriter 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.c om> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
Is there any way for System.IO.Strea mWriter 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
3056
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 to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought I'd ask other programmers what information they find useful. Below is a typical class I've...
12
2432
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 not even relative with implementation - I'm looking for a smart solution My present system works like this:
13
9647
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 assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
1
1526
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 entire write is completed successfully.
1
717
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.
28
5220
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(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
6
10217
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 message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using the same streamwriter object before deleting the original file, but it's no use. Something keeps...
20
1487
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 threads - only happens when built with the 'release' configuration (no debug flag, compiler optimizations in effect) - no problems in debug config here is the error: Unhandled Exception: System.AccessViolationException: Attempted to read or write...
7
11089
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 are no problems using the Chilkat FTP component, or connecting and browsing manually with a variety of FTP clients. The code I'm using is:
1
9263
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
9208
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
8210
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
6751
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
6053
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
4570
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
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.