FileInfo.Length プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)



ファイルを含んでいるファイル システムがこの情報をサポートしていない場合、このプロパティ値は null 参照 (Visual Basic では Nothing) です。
その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。
File.AppendText FileInfo.AppendText | |
File.Copy FileInfo.CopyTo | |
File.Move FileInfo.MoveTo | |
CreateSubdirectory | |
GetFileSystemInfos | |
SetAttributes |

' 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

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


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

- FileInfo.Length プロパティのページへのリンク