OpenFileDialog.ShowReadOnly プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As OpenFileDialog Dim value As Boolean value = instance.ShowReadOnly instance.ShowReadOnly = value
/** @property */ public boolean get_ShowReadOnly () /** @property */ public void set_ShowReadOnly (boolean value)
ダイアログ ボックスに読み取り専用チェック ボックスが表示されている場合は true。それ以外の場合はfalse。既定値は false です。

ShowReadOnly プロパティの使用方法を示すコード例を次に示します。この例では、ShowReadOnly プロパティが true に設定された OpenFileDialog ボックスを表示します。オプションをクリックしてファイルを読み取り専用モードで開くと、OpenFile メソッドを使用してファイルが開かれます。それ以外の場合は、FileStream クラスを使用して読み取り/書き込みモードでファイルが開かれます。
Private Function OpenFile() As FileStream ' Displays an OpenFileDialog and shows the read/only files. Dim DlgOpenFile As New OpenFileDialog() DlgOpenFile.ShowReadOnly = True Dim Fs As FileStream If DlgOpenFile.ShowDialog() = DialogResult.OK Then ' If ReadOnlyChecked is true, uses the OpenFile method to ' open the file with read/only access. If DlgOpenFile.ReadOnlyChecked = True Then Return DlgOpenFile.OpenFile() ' Otherwise, opens the file with read/write access. Else Dim Path As String = DlgOpenFile.FileName Return New FileStream(Path, System.IO.FileMode.Open, _ System.IO.FileAccess.ReadWrite) End If End If End Function
private FileStream OpenFile() { // Displays an OpenFileDialog and shows the read/only files. OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.ShowReadOnly = true; if(dlgOpenFile.ShowDialog() == DialogResult.OK) { // If ReadOnlyChecked is true, uses the OpenFile method to // open the file with read/only access. if(dlgOpenFile.ReadOnlyChecked == true) { return (FileStream)dlgOpenFile.OpenFile(); } // Otherwise, opens the file with read/write access. else { string path = dlgOpenFile.FileName; return new FileStream(path, System.IO.FileMode.Open , System.IO.FileAccess.ReadWrite); } } return null; }
private: FileStream^ OpenFile() { // Displays an OpenFileDialog and shows the read/only files. OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog; dlgOpenFile->ShowReadOnly = true; if ( dlgOpenFile->ShowDialog() == ::DialogResult::OK ) { // If ReadOnlyChecked is true, uses the OpenFile method to // open the file with read/only access. if ( dlgOpenFile->ReadOnlyChecked == true ) { return dynamic_cast<FileStream^>(dlgOpenFile->OpenFile()); } // Otherwise, opens the file with read/write access. else { String^ path = dlgOpenFile->FileName; return gcnew FileStream( path,System::IO::FileMode::Open,System::IO::FileAccess::ReadWrite ); } } return nullptr; }
private FileStream OpenFile() { // Displays an OpenFileDialog and shows the read/only files. OpenFileDialog dlgOpenFile = new OpenFileDialog(); dlgOpenFile.set_ShowReadOnly(true); if (dlgOpenFile.ShowDialog().Equals(get_DialogResult().OK)) { // If ReadOnlyChecked is true, uses the OpenFile method to // open the file with read/only access. if (dlgOpenFile.get_ReadOnlyChecked() == true) { return (FileStream)dlgOpenFile.OpenFile(); } // Otherwise, opens the file with read/write access. else { String path = dlgOpenFile.get_FileName(); return new FileStream(path, System.IO.FileMode.Open , System.IO.FileAccess.ReadWrite); } } return null; } //OpenFile

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からOpenFileDialog.ShowReadOnly プロパティを検索する場合は、下記のリンクをクリックしてください。

- OpenFileDialog.ShowReadOnly プロパティのページへのリンク