>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.
You could put try...catch in a loop w/o throwing the error. At the end of the loop if loFile is null throw.
Cetin