Solved

Read file and then write to it

Posted on 2006-10-26
3
154 Views
Last Modified: 2010-04-23
I have a script and I need to document how many times a certain procedure is being used.  I would just like to write this out to a text file to look like:

10-26-2006 20
10-27-2006 55
10-28-2006 20

Total=95

I will 6 people all using the same script and would like this written to a text file in a shared location.  I doubt anyone would be using this at the same time, but I guess it could happen.  I have never written to a text file and not really sure how to set this up since it needs to read the file to get a number, then add +1 to this number.  I guess it also must know what date it is to see if it needs to start  new date.

Thanks, Chad
0
Comment
Question by:chadmanvb
3 Comments
 
LVL 10

Expert Comment

by:gangwisch
ID: 17816741
Dim fs As New FileStream("c:\file.txt", FileMode.Append)
        Dim sw As New StreamWriter(fs)
        sw.WriteLine("Hello")

make sure you import system.io
0
 
LVL 12

Accepted Solution

by:
sandip132 earned 500 total points
ID: 17817431
for your requirement its better to use XML as your database...
Ref. this for the details : http://www.codeguru.com/vb/gen/vb_database/adonet/article.php/c5153/
0
 
LVL 5

Expert Comment

by:xersoft
ID: 17819024
I agree with sandip132. You will have better luck if you move to some other structure. You will run into problems when multiple people hit the file at the same time, if it ever happens. And at some point your app will slow down due to the large number of lines in the file.

I’m not sure of the scope of your available options but one thing you could do:

Setup a web service, which is called by the app.
Make the web service write to a common location, say a database of some sorts.

Even though a database is just a fancy “file”, it provides a means to manage multiple streams of data coming in at or near the same time. By using the database you are able to “ignore” this aspect and just write to the database.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now