Guys,

I am trying to create a function that will take a FolderPath as an arguement, then check to see if ...
1 - The folder exists
2 - The user have write access

I need the function to return true if the folder exists and the user has write perms, otherwise false.

This is what I have so far but it doesn't seem to be doing much... its returning true if the folder doesn't exist.

Thanks
Bob

VB Code:
  1. Public Function CheckFilePermissions(ByVal CheckPath As String, ByVal Foldername As String) As Boolean
  2.  
  3.         Dim permFileIO As FileIOPermission = New FileIOPermission(FileIOPermissionAccess.Write, CheckPath)
  4.         Try
  5.             permFileIO.Demand()
  6.             Return True
  7.         Catch ex As Exception
  8.             MessageBox.Show("The " & Foldername & "for this contract does not exist," & _
  9.             vbCrLf & "or you do not have the correct permissions to write to it." & _
  10.             vbCrLf & vbCrLf & "Please contact the IT Helpdesk if you need help resolving this issue. Quote PWB003" & _
  11.             vbCrLf & vbCrLf & CheckPath, "Document Folder Error (PWB003)", MessageBoxButtons.OK, MessageBoxIcon.Error)
  12.             Return False
  13.         End Try
  14.  
  15.     End Function