Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
 
            Try
                FileOpen(tmpFileNum, iFlName, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, RecordLength)
                t = True
                Exit For
 
            Catch ex
 
            End Try
 
        Else
            Threading.Thread.Sleep(1000)
 
        End If
 
    Next i
 
    If t = False Then
        MsgBox(ex.ToString)
        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
good
Please Sign up or sign in to vote.

Solution 1

I suggest you to ask this question on AWS forum: https://forums.aws.amazon.com/forum.jspa?forumID=61[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 349
1 Nirav Prabtani 268
2 Richard Deeming 215
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
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