Click here to Skip to main content
12,893,131 members (61,995 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
The data for my application is being stored on AWS S3. When users make changes to any of the data files (and are connected to AWS), the save routines automatically upload the data fiels to AWS. This seems to be working fine.

The application also automatically downloads the data files if the local file is out of date by more than 2 seconds. This is done in a secondary thread.

The problem is, if I try to open the file while it is downloading, an error is thrown. I tried to trap for this using file attributes, but it doesn't seem to be working correctly. Here is the file open sub in my CDataFile utility class:

' return the file number if successful, else return -1
Public Function OpenNewFile() As Short
    ' Open the data file
    Dim tmpFileNum As Short = FreeFile()
    Dim iFlName As String = FullFileName()
    Dim t As Boolean = False
    Dim ex As Exception = Nothing
    For i As Byte = 0 To 15 Step 1
        Dim t1 As Short = System.IO.File.GetAttributes(iFlName)
        If Not (t1 = FileAttributes.Offline) Then
                FileOpen(tmpFileNum, iFlName, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, RecordLength)
                t = True
                Exit For
            Catch ex
            End Try
        End If
    Next i
    If t = False Then
        tmpFileNum = -1
    End If
    Return tmpFileNum
End Function

Is there is a better method to trap for a file that is being downloaded?

Does the file attribute "Offline" return the correct value if the file is being downloaded?
Posted 11-Feb-13 11:46am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I suggest you to ask this question on AWS forum:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100