How to check the filrsize in a directory

I have a file in windows directory and all I need to do is check the filesize and update that in the database and need something simple as I am not really doing anything else with the file. Any ideas?, I am using vb.net(c# also should work)
welcome 123Asked:
Who is Participating?
 
Lokesh B RDeveloperCommented:
Hi,

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);
    }
}

Open in new window


https://msdn.microsoft.com/en-us/library/system.io.fileinfo.length(v=vs.110).aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.