473,811 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Edit text file?

I have a text file which stores user input. Later if user edited the input
data from a input form. How can I update the input text file? If update the
text file too often, would it cause problem?

Thanks in advance for any help.

Nov 21 '05 #1
11 2145
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
I have a text file which stores user input. Later if user edited the
input
data from a input form. How can I update the input text file?
For small text files, the simplest solution is to rewrite the whole file.
This doesn't mean deleting the file and then creating a new one, but it
means setting the file's length to 0 using 'FileStream.Set Length' and then
write the data to the file using 'System.IO.Stre amWriter'.
If update the text file too often, would it cause problem?


This depends on the size of the file and the intervalls between the updates.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Thank you so much for your help. Will 5 to 10 pages's text file be
considered as a small text file?

Nina

"Herfried K. Wagner [MVP]" wrote:
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
I have a text file which stores user input. Later if user edited the
input
data from a input form. How can I update the input text file?


For small text files, the simplest solution is to rewrite the whole file.
This doesn't mean deleting the file and then creating a new one, but it
means setting the file's length to 0 using 'FileStream.Set Length' and then
write the data to the file using 'System.IO.Stre amWriter'.
If update the text file too often, would it cause problem?


This depends on the size of the file and the intervalls between the updates.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
Will 5 to 10 pages's text file be
considered as a small text file?


I consider everything < 10 KB a "small file", but that's only my personal
opinion.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Since the text file that I'm working on is about 50 KB, I cannot use the way
you suggested previously. Is there any way that fits my application?

Thanks again.

Nina

"Herfried K. Wagner [MVP]" wrote:
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
Will 5 to 10 pages's text file be
considered as a small text file?


I consider everything < 10 KB a "small file", but that's only my personal
opinion.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:OW******** ********@TK2MSF TNGP14.phx.gbl. ..
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
Will 5 to 10 pages's text file be
considered as a small text file?


I consider everything < 10 KB a "small file", but that's only my personal
opinion.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Herfried --

If the data stored in her file is structured in the

keyname=value

format does VB.Net have a replacement for the old
WritePrivatePro fileString and GetPrivateProfi leString
API calls? I'm new to .Net and many of my old VB6
programs use these functions to store and update user data.
As I convert the old projects to .Net I'd like to use the
framework if possible.

Jim Edgar
Nov 21 '05 #6
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
Since the text file that I'm working on is about 50 KB, I cannot use the
way
you suggested previously. Is there any way that fits my application?


What data are you storing?
How often do you store it?
How often do you read the data?
....

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7
> What data are you storing?
Below is a sample text file:

Subcatchment Name=sub
ID=1
Description=gri d
Area=100
Length=800
Slop=4
%Impervious=10
N-Impervious=0.01
N-Pervious=0.05
DStore-Impervious=1.5
Dstore-Pervious=4.5
Model=Horton
End

Statistics
Location=Chicag o
Volume=18.86
Duration=7.73
Time=103.1
Annual Number of Events=57.2
End

sub Infil Data
Max. Infil=25.4
Min. Infil=0.36
Decay Constant=4.14
Recovery Constant=0.005
End
How often do you store it?
How often do you read the data? For these two questions, it depends on how often user changes those inputs.
It is possible that user edit those valumes frequently. Well, what I'm trying
to do is to read the text file and put it into a global arraylist when user
opens the project. While user working with the project, I just simply update
the arraylist. When user close the project, then I writ e the arraylist back
to the text file. Do you think this is a good way to handle it?

Thanks again.

Nina

"Herfried K. Wagner [MVP]" wrote:
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
Since the text file that I'm working on is about 50 KB, I cannot use the
way
you suggested previously. Is there any way that fits my application?


What data are you storing?
How often do you store it?
How often do you read the data?
....

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
What data are you storing?

Below is a sample text file:

Subcatchment Name=sub
ID=1
Description=gri d
Area=100
Length=800
Slop=4
%Impervious=10
N-Impervious=0.01
N-Pervious=0.05
DStore-Impervious=1.5
Dstore-Pervious=4.5
Model=Horton
End

Statistics
Location=Chicag o
Volume=18.86
Duration=7.73
Time=103.1
Annual Number of Events=57.2
End

sub Infil Data
Max. Infil=25.4
Min. Infil=0.36
Decay Constant=4.14
Recovery Constant=0.005
End
How often do you store it?
How often do you read the data?

For these two questions, it depends on how often user changes those
inputs.
It is possible that user edit those valumes frequently. Well, what I'm
trying
to do is to read the text file and put it into a global arraylist when
user
opens the project. While user working with the project, I just simply
update
the arraylist. When user close the project, then I writ e the arraylist
back
to the text file. Do you think this is a good way to handle it?

I think that's a good way!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9
"Nina" <Ni**@discussio ns.microsoft.co m> schrieb:
What data are you storing?

Below is a sample text file:

Subcatchment Name=sub
ID=1
Description=gri d
Area=100
Length=800
Slop=4
%Impervious=10
N-Impervious=0.01
N-Pervious=0.05
DStore-Impervious=1.5
Dstore-Pervious=4.5
Model=Horton
End

Statistics
Location=Chicag o
Volume=18.86
Duration=7.73
Time=103.1
Annual Number of Events=57.2
End

sub Infil Data
Max. Infil=25.4
Min. Infil=0.36
Decay Constant=4.14
Recovery Constant=0.005
End
How often do you store it?
How often do you read the data?

For these two questions, it depends on how often user changes those
inputs.
It is possible that user edit those valumes frequently. Well, what I'm
trying
to do is to read the text file and put it into a global arraylist when
user
opens the project. While user working with the project, I just simply
update
the arraylist. When user close the project, then I writ e the arraylist
back
to the text file. Do you think this is a good way to handle it?

I think that's a good way!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #10

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

Similar topics

6
4276
by: matt | last post by:
I am using a text file as a database, each field delimited by || I want to be able to print all lines to a page, then by selecting one (with, say, a radio button) it will load into the form at the bottom of the page, where I can edit the fields, and save back to the same line in the text file. I dont know how to use primary keys or anything with a text file database, any help in this would be appreciated! Thanks matt
4
15575
by: Option^Explicit | last post by:
What I'm trying to do: Open a text file and display the contents in a text box (I've done this) Need to be able to edit the file from within the textbox and have it save back to the source file.(can't figure how to do this) I was thinking on the Open for Output or Append, but I can't get it to accept a variable(TextBoxText) to open(since it's not a file) , what would be the simplest way to accomplish this task?
4
10155
by: Abhishek | last post by:
Hi! I need to edit a text file. I need to replace a given text in the file with a new one. This text can exist anywhere in the file, so i first need to locate the text position and then edit it. How do i acheive this.
0
3120
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format. However, the DataGrid begins to get very cumbersome as the number of columns of data you present increases. Anything more than half a dozen columns or so and you probably induce horizontal scrolling - a real no-no for me. If you put such a...
0
1769
by: Alex | last post by:
Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Public Class Main : Inherits Page Private strConn As String =
4
3721
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
2
4178
by: Sin | last post by:
Hello everyone, I'm totally stumped at how little info I can find in MSDN or on the web concerning this. It's almost as if only microsoft personel hold the key to these secrets or something!!! I'm currently writting a program in which there is a file/folder list which mimics part of Explorer's list. I've got it pretty much cornered, but I still have a couple of problems :
1
2168
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is I have Categories and various Products in each Category. I'm trying to build a page to EDIT/UPDATE each product.I want to be able to change the Category that a product belongs to, but all I get in the drop-down menu is the one specific Category. ...
1
2137
by: Xicon | last post by:
I am looking to create a program that is able to edit a text file that is not located within the program. This particular text file is always in the exact same location and is always named the exact same, and I would like to find a way to make it easily editable. How do I edit the text file (a single line needs to be changed) using a Visual Basic 2008 program? Please help me, I will be VERY appreciative! EDIT: I use Visual Basic 2008...
0
1296
by: yemen2007 | last post by:
hi i have some problem in my project i want help . the problem it is update or edit to the file in xml.my project is write and update/edit to xml file. i done the first one is write bout i have problem in the update/edit function . i write some value inside file i want change the value that one in the file. i use c# so could u plz help me in this function. this the code for write : XmlTextWriter f = new XmlTextWriter("website...
0
9605
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,...
0
10648
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10402
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
10135
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
6890
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
5554
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
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
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...

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.