?
Solved

Read file and then write to it

Posted on 2006-10-26
3
Medium Priority
?
211 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 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 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