Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining last update of a file when it is in construc
Message
From
25/03/2014 17:00:22
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01597298
Message ID:
01597335
Views:
30
I tested that code. Here is my conversion:
    ' If a file is ready
    Public Function IsFileReady() As Boolean
        Dim lcFile As String = ""
        Dim llSuccess As Boolean = False

        ' Reset the values
        lIsFileReady = False

        ' Initialization
        lcFile = Trim(cFile)

        ' If the file is empty
        If lcFile.Length = 0 Then
            cMessage = cYouNeedToDefineTheCFileProperty
            Return False
        End If

        ' If the file can be opened for exclusive access it means that the file is no longer locked by another process
        Try

            ' Try to open the file for exclusive access
            Using loFileStream As System.IO.FileStream = System.IO.File.Open(lcFile, _
             System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None)
                lIsFileReady = loFileStream.Length >= 0
            End Using

            llSuccess = True
        Catch loError As System.Exception
            cMessage = loError.Message
        End Try

        ' Reset the values
        cFile = ""

        Return llSuccess
    End Function
I uploaded the 180 MB file. I run this code while the upload was in progress. The Try/Catch falls in the Catch as it says "The process cannot access the file 'FullFilePathHere' because it is being used by another process."

There must be something I am missing. The Using command is failing on such occasion.
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
Reply
Map
View

Click here to load this message in the networking platform