Solved

I want a Code

Posted on 2004-03-24
5
149 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 63 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 62 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

734 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