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:
Public Function CheckFilePermissions(ByVal CheckPath As String, ByVal Foldername As String) As Boolean Dim permFileIO As FileIOPermission = New FileIOPermission(FileIOPermissionAccess.Write, CheckPath) Try permFileIO.Demand() Return True Catch ex As Exception MessageBox.Show("The " & Foldername & "for this contract does not exist," & _ vbCrLf & "or you do not have the correct permissions to write to it." & _ vbCrLf & vbCrLf & "Please contact the IT Helpdesk if you need help resolving this issue. Quote PWB003" & _ vbCrLf & vbCrLf & CheckPath, "Document Folder Error (PWB003)", MessageBoxButtons.OK, MessageBoxIcon.Error) Return False End Try End Function




Reply With Quote