?
Solved

I want a Code

Posted on 2004-03-24
5
Medium Priority
?
151 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
[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
5 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 252 total points
ID: 10668839
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 248 total points
ID: 10669050
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

777 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