Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recommendation on accessing a file
Message
From
21/09/2006 20:10:55
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Recommendation on accessing a file
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01156238
Message ID:
01156238
Views:
64
This message might be returned as an error:

"The process cannot access the file 'D:\iis\Direct Martial Arts\BannerRight3.html' because it is being used by another process."

when the VB.NET application is trying to access BannerRight3.html at the same time the robot application is storing it on the drive. This is done every minute. So, there could be a collision.

This is the method that triggers it:
        ' FileToStr() VFP equivalent
        ' expC1 File name
        Public Function FileToStr(ByVal tcFileName As String) As String
            Dim lcString As String = ""
            Dim loFile As IO.StreamReader
            Try
                loFile = New IO.StreamReader(tcFileName, True)
                lcString = loFile.ReadToEnd()
                loFile.Close()
            Catch loError As Exception

                ' 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
            Return lcString
        End Function
I was wondering if there could be a good mechanism to have this FileToStr() method to retry or wait or something like that which would make it more solid. Basically, I wouldn't want to retry indefinitely. Maybe just one or two seconds. But, before using that approach, I was wondering if there would be something in regards to the StreamReader() that could help me.
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
Next
Reply
Map
View

Click here to load this message in the networking platform