本文整理匯總了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