Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Read file and then write to it

Posted on 2006-10-26
3
179 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

789 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