本文整理汇总了VB.NET中System.Windows.Forms.OpenFileDialog.ShowReadOnly属性的典型用法代码示例。如果您正苦于以下问题:VB.NET OpenFileDialog.ShowReadOnly属性的具体用法?VB.NET OpenFileDialog.ShowReadOnly怎么用?VB.NET OpenFileDialog.ShowReadOnly使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.ShowReadOnly属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: OpenFile
Private Function OpenFile() As FileStream
' Displays an OpenFileDialog and shows the read/only files.
Dim DlgOpenFile As New OpenFileDialog()
DlgOpenFile.ShowReadOnly = True
If DlgOpenFile.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim path As New String("")
' If ReadOnlyChecked is true, uses the OpenFile method to
' open the file with read/only access.
Try
If (DlgOpenFile.ReadOnlyChecked = True) Then
Return DlgOpenFile.OpenFile()
Else
' Otherwise, opens the file with read/write access.
Path = DlgOpenFile.FileName
Return New FileStream(Path, System.IO.FileMode.Open, _
System.IO.FileAccess.ReadWrite)
End If
Catch SecEx As SecurityException
' The user lacks appropriate permissions to read files, discover paths, etc.
MessageBox.Show("Security error. Please contact your administrator for details.\n\n" & _
"Error message: " & SecEx.Message * "\n\n" & _
"Details (send to Support):\n\n" & SecEx.StackTrace)
Catch Ex As Exception
' Could not load the image - probably related to Windows file system permissions.
MessageBox.Show("Cannot display the image: " & path.Substring(path.LastIndexOf("\\")) & _
". You may not have permission to read the file, or " & _
"it may be corrupt.\n\nReported error: " + ex.Message)
End Try
End If
Return Nothing
End Function