Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Find the size of a specified file in bytes

C# Sharp Basic: Exercise-29 with Solution

Write a C# program to find the size of a specified file in bytes.

C# Sharp Exercises: Find the size of a specified file in bytes

Sample Solution:-

C# Sharp Code:

using System;
using System.Collections.Generic;
using System.IO;

public class Exercise29 {
 public static void Main() {
        FileInfo f = new FileInfo("/home/students/abc.txt");
        Console.WriteLine("\nSize of a file: "+f.Length.ToString());
 }
}

Sample Output:

Size of a file: 31 

Flowchart:

Flowchart: C# Sharp Exercises - Find the size of a specified file in bytes

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# program to reverse the words of a sentence.
Next: Write a C# program to convert a hexadecimal number to decimal number.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.