Solved

Read file and then write to it

Posted on 2006-10-26
3
192 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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