Stream.CanWrite プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Stream.CanWrite プロパティの意味・解説 

Stream.CanWrite プロパティ

派生クラスでオーバーライドされた場合は、現在のストリームが書き込みをサポートするかどうかを示す値を取得します。

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

CanWrite プロパティの使用例を次に示します。

Imports System
Imports System.IO

Class TestRW    

    Public Shared Sub Main()
        Dim fs As New FileStream("MyFile.txt",
 FileMode.OpenOrCreate, _
           FileAccess.Write)
        If fs.CanRead And fs.CanWrite Then
            Console.WriteLine("MyFile.txt can be both written
 to and read from.")
        Else
            If fs.CanWrite Then
                Console.WriteLine("MyFile.txt is writable.")
            End If
        End If
    End Sub
End Class

'This code outputs "MyFile.txt is writable."
'To get the output message "MyFile.txt can be both written to and
 read from.",
'change the FileAccess parameter to ReadWrite in the FileStream constructor.
using System;
using System.IO;

class TestRW 
{
  public static void Main(String[]
 args)
  { 
    FileStream fs = new FileStream("MyFile.txt", FileMode.OpenOrCreate
,
       FileAccess.Write);
    if (fs.CanRead && fs.CanWrite) {
        Console.WriteLine("MyFile.txt can be both written to and read from.");
    }
    else if (fs.CanWrite) {
        Console.WriteLine("MyFile.txt is writable.");
    }
  }
}
//This code outputs "MyFile.txt is writable."
//To get the output message "MyFile.txt can be both written to
 and read from.",
//change the FileAccess parameter to ReadWrite in the FileStream constructor.
using namespace System;
using namespace System::IO;
int main()
{
   FileStream^ fs = gcnew FileStream( "MyFile.txt",FileMode::OpenOrCreate,FileAccess::Write
 );
   if ( fs->CanRead && fs->CanWrite )
   {
      Console::WriteLine( "MyFile.txt can be both written to and read from."
 );
   }
   else
   if ( fs->CanWrite )
   {
      Console::WriteLine( "MyFile.txt is writable." );
   }
}

//This code outputs "MyFile.txt is writable."
//To get the output message "MyFile.txt can be both written to
 and read from.",
//change the FileAccess parameter to ReadWrite in the FileStream constructor.
import System.*;
import System.IO.*;

class TestRW
{
    public static void main(String[]
 args)
    {
        FileStream fs = new FileStream("MyFile.txt",
 
            FileMode.OpenOrCreate, FileAccess.Write);
        if (fs.get_CanRead() && fs.get_CanWrite()) {
            Console.WriteLine(
                "MyFile.txt can be both written to and read from.");
        }
        else {
            if (fs.get_CanWrite()) {
                Console.WriteLine("MyFile.txt is writable.");
            }
        }
    } //main
} //TestRW

//This code outputs "MyFile.txt is writable."
//To get the output message "MyFile.txt can be both written to
 and read from.",
//change the FileAccess parameter to ReadWrite in the FileStream constructor.
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Stream.CanWrite プロパティ」の関連用語

Stream.CanWrite プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Stream.CanWrite プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS