Subject: Security permissions of file
Posted By: eelisMX Post Date: 10/4/2005 5:33:20 AM
Hi

I'm trying to check a file for its security permissions to determine if it is writeable or not.
The code looks like that:

Function IsFileWritePermission(ByVal sFileName As String) As Boolean
        Try
            Dim fp As FileIOPermission
            fp = New FileIOPermission(FileIOPermissionAccess.Write, sFileName)
            
            fp.Demand()

            Return True
        Catch ex As Security.SecurityException
            Return False
        Catch ex As Exception
            Return False
        End Try
    End Function


The file i'm testing has a Deny Write permission and the function still return true. If I try to open the file to write, it raises an error exception for write permission.

Thanks.

Go to topic 35331

Return to index page 460
Return to index page 459
Return to index page 458
Return to index page 457
Return to index page 456
Return to index page 455
Return to index page 454
Return to index page 453
Return to index page 452
Return to index page 451