Solved

I want a Code

Posted on 2004-03-24
5
143 Views
Last Modified: 2010-05-01
I want to read a text file in a folder atonce it is saved in the folder.
Thing is the file will be exist in the folder only for one or two seconds before that I have to read that, after couple of seconds file will be automatically deleted by some other application so our program has to wait for the arrival of the file once it comes in the folder our program has to read the file.. Will you please give me the code.
Expecting your favourable and prompt reply.

0
Comment
Question by:Ezhil7
5 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 63 total points
Comment Utility
If you are using .Net you can set up a filewatcher and read the file that way.  

http://www.ftponline.com/vsm/2004_02/magazine/columns/gettingstarted/

0
 
LVL 3

Assisted Solution

by:Bobeo
Bobeo earned 62 total points
Comment Utility
This worked for me in VB 6

You need a Microsoft Scripting Runtime Reference on your project and a timer and a textbox on your form.  Set the timer interval to 100


Dim FSO As New FileSystemObject
Dim FileName As String
Dim TXT As TextStream
Dim FileText As String
dim FileRead as boolean

Private Sub Form_Load()
FileRead = False
end sub

Private Sub Timer1_Timer()
if FileRead = False then
On Error GoTo Errors
FileName = App.Path & "\Text.txt"
Set TXT = FSO.OpenTextFile(FileName, ForReading, False)

FileText = TXT.ReadAll
Text1 = FileText

FileRead = True
Timer1.Enabled = False

end if

Exit Sub

Errors:
Exit Sub
End Sub


Hope it works for you!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

19 Experts available now in Live!

Get 1:1 Help Now