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

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

FileStream.CanSeek プロパティ

現在のストリームシークサポートしているかどうかを示す値を取得します

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

解説解説

Stream から派生したクラスシークサポートしてない場合に、Length、SetLength、Position、および Seek呼び出すと、NotSupportedException がスローさます。

ストリーム閉じている場合、このプロパティfalse返します

使用例使用例

CanSeek プロパティ使用してストリームシークサポートしているかどうか確認する例を次に示します

Imports System
Imports System.IO

Public Class Test

    Public Shared Sub Main()
        Dim path As String
 = "c:\temp\MyTest.txt"

        ' Delete the file if it exists.
        If File.Exists(path) Then
            File.Delete(path)
        End If

        'Create the file.
        Dim fs As FileStream = File.Create(path)

        If fs.CanSeek Then
            Console.WriteLine("The stream connected to {0} is
 seekable.", path)
        Else
            Console.WriteLine("The stream connected to {0} is
 not seekable.", path)
        End If

        fs.Close()
    End Sub
End Class
using System;
using System.IO;
using System.Text;

class Test 
{
    
    public static void Main()
 
    {
        string path = @"c:\temp\MyTest.txt";

        // Delete the file if it exists.
        if (File.Exists(path)) 
        {
            File.Delete(path);
        }

        //Create the file.
        using (FileStream fs = File.Create(path)) 
        {
            if (fs.CanSeek) 
            {
                Console.WriteLine("The stream connected to {0} is seekable.",
 path);
            } 
            else 
            {
                Console.WriteLine("The stream connected to {0} is not seekable.",
 path);
            }
        }
    }
}
using namespace System;
using namespace System::IO;
using namespace System::Text;

int main()
{
   String^ path = "c:\\temp\\MyTest.txt";
   
   // Delete the file if it exists.
   if ( File::Exists( path ) )
   {
      File::Delete( path );
   }

   //Create the file.
   FileStream^ fs = File::Create( path );
   try
   {
      if ( fs->CanSeek )
      {
         Console::WriteLine( "The stream connected to {0} is seekable.",
 path );
      }
      else
      {
         Console::WriteLine( "The stream connected to {0} is not seekable.",
 path );
      }
   }
   finally
   {
      if ( fs )
         delete (IDisposable^)fs;
   }
}
import System.*;
import System.IO.*;
import System.Text.*;

class Test
{
    public static void main(String[]
 args)
    {
        String path = "c:\\temp\\MyTest.txt";

        // Delete the file if it exists.
        if (File.Exists(path)) {
            File.Delete(path);
        }
        //Create the file.
        FileStream fs = File.Create(path);
        try {
            if (fs.get_CanSeek()) {
                Console.WriteLine("The stream connected to {0} " 
                    + "is seekable.", path);
            }
            else {
                Console.WriteLine("The stream connected to {0} is not "
 
                    + " seekable.", path);
            }
        }
        finally {
            fs.Dispose();
        }

    } //main
} //Test
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



FileStream.CanSeek プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS