本文整理汇总了VB.NET中System.IO.FileInfo.Length属性的典型用法代码示例。如果您正苦于以下问题:VB.NET FileInfo.Length属性的具体用法?VB.NET FileInfo.Length怎么用?VB.NET FileInfo.Length使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.IO.FileInfo 的用法示例。
在下文中一共展示了FileInfo.Length属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: FileLength
' The following example displays the names and sizes
' of the files in the specified directory.
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
End Class
'This code produces output similar to the following;
'results may vary based on the computer/file structure/etc.:
'
'The directory c:\ contains the following files:
'The size of MyComputer.log is 274 bytes.
'The size of AUTOEXEC.BAT is 0 bytes.
'The size of boot.ini is 211 bytes.
'The size of CONFIG.SYS is 0 bytes.
'The size of hiberfil.sys is 1072775168 bytes.
'The size of IO.SYS is 0 bytes.
'The size of MASK.txt is 2700 bytes.
'The size of mfc80.dll is 1093632 bytes.
'The size of mfc80u.dll is 1079808 bytes.
'The size of MSDOS.SYS is 0 bytes.
'The size of NTDETECT.COM is 47564 bytes.
'The size of ntldr is 250032 bytes.
'The size of pagefile.sys is 1610612736 bytes.
'The size of UpdatePatch.log is 22778 bytes.
'The size of UpdatePatch.txt is 30 bytes.
'The size of wt3d.ini is 234 bytes.
开发者ID:VB.NET开发者,项目名称:System.IO,代码行数:40,代码来源:FileInfo.Length
示例2: Module1
' 导入命名空间
Imports System.IO
Module Module1
Sub Main()
Dim Root As New DirectoryInfo("C:\")
Dim Files As FileInfo() = Root.GetFiles("*.*")
Dim Dirs As DirectoryInfo() = Root.GetDirectories("*.*")
Console.WriteLine("Root Files")
Dim Filename As FileInfo
For Each Filename In Files
Try
Console.Write(Filename.FullName)
Console.Write(" Size: {0} bytes", Filename.Length)
Console.WriteLine(" Last use: {0}", Filename.LastAccessTime)
Catch E As Exception
Console.WriteLine("Error accessing File")
End Try
Next
End Sub
End Module
开发者ID:VB程序员,项目名称:System.IO,代码行数:26,代码来源:FileInfo.Length
注:本文中的System.IO.FileInfo.Length属性示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论