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

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

FileInfo.Length プロパティ

現在のファイルサイズ取得します

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

例外例外
例外種類条件

IOException

Refresh によってファイルまたはディレクトリの状態を更新できません。

FileNotFoundException

ファイル存在しません。

または

Length プロパティディレクトリに対して呼び出されます。

解説解説
使用例使用例

指定したファイルサイズ表示する例を次に示します

' The following example displays the names and sizes
' of the files in the specified directory.
Imports System
Imports System.IO

Public Class FileLength

    Public Shared Sub Main()
        ' Make a reference to a directory.
        Dim di As New DirectoryInfo("c:\")
        ' Get a reference to each file in that directory.
        Dim fiArr As FileInfo() = di.GetFiles()
        ' Display the names and sizes of the files.
        Dim f As FileInfo
        Console.WriteLine("The directory {0} contains the following
 files:", di.Name)
        For Each f In fiArr
            Console.WriteLine("The size of {0} is {1} bytes.",
 f.Name, f.Length)
        Next f
    End Sub 'Main
End Class 'FileLength 
// The following example displays the names and sizes
// of the files in the specified directory.
using System;
using System.IO;

public class FileLength
{
    public static void Main()
    {
        // Make a reference to a directory.
        DirectoryInfo di = new DirectoryInfo("c:\\");
        // Get a reference to each file in that directory.
        FileInfo[] fiArr = di.GetFiles();
        // Display the names and sizes of the files.
        Console.WriteLine("The directory {0} contains the following files:"
,
 di.Name);
        foreach (FileInfo f in fiArr)
            Console.WriteLine("The size of {0} is {1} bytes.", f.Name,
 f.Length);
    }
}
// The following example displays the names and sizes
// of the files in the specified directory.
using namespace System;
using namespace System::IO;
int main()
{
   
   // Make a reference to a directory.
   DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" );
   
   // Get a reference to each file in that directory.
   array<FileInfo^>^fiArr = di->GetFiles();
   
   // Display the names and sizes of the files.
   Console::WriteLine( "The directory {0} contains the following files:",
 di->Name );
   System::Collections::IEnumerator^ myEnum = fiArr->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      FileInfo^ f = safe_cast<FileInfo^>(myEnum->Current);
      Console::WriteLine( "The size of {0} is {1} bytes.", f->Name,
 f->Length );
   }
}

// The following example displays the names and sizes
// of the files in the specified directory.
import System.*;
import System.IO.*;

public class FileLength
{
    public static void main(String[]
 args)
    {
        // Make a reference to a directory.
        DirectoryInfo di = new DirectoryInfo("c:\\");

        // Get a reference to each file in that directory.
        FileInfo fiArr[] = di.GetFiles();

        // Display the names and sizes of the files.
        Console.WriteLine("The directory {0} contains the following files:"
,
            di.get_Name());
        for (int iCtr = 0; iCtr < fiArr.length;
 iCtr++) {
            FileInfo f = fiArr[iCtr];
            Console.WriteLine("The size of {0} is {1} bytes.", f.get_Name()
,
                System.Convert.ToString(f.get_Length()));
        }
    } //main
} //FileLength
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からFileInfo.Length プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFileInfo.Length プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFileInfo.Length プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「FileInfo.Length プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS