本文整理汇总了VB.NET中System.Windows.Forms.OpenFileDialog.ReadOnlyChecked属性的典型用法代码示例。如果您正苦于以下问题:VB.NET OpenFileDialog.ReadOnlyChecked属性的具体用法?VB.NET OpenFileDialog.ReadOnlyChecked怎么用?VB.NET OpenFileDialog.ReadOnlyChecked使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.OpenFileDialog 的用法示例。
在下文中一共展示了OpenFileDialog.ReadOnlyChecked属性的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
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:36,代码来源:OpenFileDialog.ReadOnlyChecked
注:本文中的System.Windows.Forms.OpenFileDialog.ReadOnlyChecked属性示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论