C# Get the number of bytes of a file

王林
Release: 2023-09-14 12:33:02
forward
1257 people have browsed it

C# 获取文件的字节数

The FileInfo type has a Length property that determines how many bytes the file is.

First, set up the file -

FileInfo file = new FileInfo("D:\ew");
Copy after login

Now use the length attribute -

file.Length
Copy after login

Here is the complete code -

Example

using System;
using System.Linq;
using System.IO;
class Program {
   static void Main() {
      FileInfo file = new FileInfo("D:\ew");
      long res = file.Length;
      Console.WriteLine("Bytes: "+res);
   }
}
Copy after login

Output

The following is the output-

3259244
Copy after login

The above is the detailed content of C# Get the number of bytes of a file. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template