473,394 Members | 1,759 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,394 software developers and data experts.

How to append data to file and clear it when it's closed

2
I have values changing at some rate per second that i am storing in a variable then i am printing these values in a file. So i have to append the values into the file so that they are not over written and all the values are displayed line by line. But when i close the program i need the file to be cleared. But only when i close the program and not when the function exits that it clears the file.
May 19 '11 #1
1 1086
To append the data to a file use:

Expand|Select|Wrap|Line Numbers
  1. File.AppendAllText("myfile.txt","I am a C# developer");
use \r\n to write in the new Line.

To clear the file while closing write the Code in the form's Dispose method
May 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SunX | last post by:
Question from a newbie. How do you write out a data file of floating point numbers? file.write only takes strings. Many thanks.
1
by: Girish | last post by:
I need to run a query which will pull data from two tables and append it as one when it displays the result. The data are in two tables. But the result set will be identical in terms of number of...
7
by: Bob | last post by:
Hi, I am trying to use BULK INSERT with format file. All of our data has few bytes of header in the data file which I would like to skip before doing BULK INSERT. Is it possible to write...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
14
by: vbMark | last post by:
Greetings, This seems like it should be simple but I can't figure out how to do this. I just want to append binary file 2 on to the end of binary file 1. Sample code please? Thanks!
6
by: Reggie | last post by:
Hi and TIA. I have an OleDB connection to an Access db which I connect to and place data from a table into a recordset. What I want to do is copy this recordset to an SQL table. I have no...
3
by: premMS143 | last post by:
How to append Data to an existing Excel file? means, I'm using VB as front end & once I exported the data to Excel file & saved it as 'ABC.xls'. Now, the question/doubt is; I addded some more...
4
by: Busbait | last post by:
Hi, I have the following code which works fine in MS Access 2007. It export current access form records to an excel sheet: DoCmd.OutputTo acOutputQuery, "RunQuery", acFormatXLSX, , True Is...
6
by: Dave067 | last post by:
Hi This is my first attempt at writing Python script - it's probably a bit ambitious, but there again, whatever doesn't kill you makes you stronger... ;-) I'm trying to write a script for a...
1
by: Namitha Bhat | last post by:
Hi ALL, This realates to vb script code to append a file in C Drive in a remote machine accessed from a machine in different domain. I am able to successfully connect to the machine, but the file...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.