Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recommendation on accessing a file
Message
From
21/09/2006 22:15:32
 
 
To
21/09/2006 20:17:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01156238
Message ID:
01156253
Views:
13
For now, I have enhanced the method like this:
        ' FileToStr() VFP equivalent
        ' expC1 File name
        Public Function FileToStr(ByVal tcFileName As String) As String
            Dim lcString As String = ""
            Dim lnCounter As Integer = 0
            Dim lnDelay As Integer = 250
            Dim lnRetry As Integer = 8
            Dim loFile As IO.StreamReader
            For lnCounter = 1 To lnRetry
                Try
                    loFile = New IO.StreamReader(tcFileName, True)
                    lcString = loFile.ReadToEnd()
                    loFile.Close()
                Catch loError As Exception

                    ' If we have not reached the maximum tries of 8, we retry
                    If lnCounter < 8 Then

                        ' Wait for a timeout before retrying
                        System.Threading.Thread.Sleep(lnDelay)

                        Continue For
                    End If

                    ' Get the proper definition as per the current scope
                    If oProcess Is Nothing Then
                        oApp.ErrorSetup(loError)
                    Else
                        oProcess.ErrorSetup(loError)
                    End If

                End Try
            Next
            Return lcString
        End Function
It has a maximum retries to 8 and an interval of .25 second.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform