Get file size of file.

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
Hi

I want to get the file size of a file.
Read in other topic you need to use the code shown on this page: http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length.aspx

Tried to use the example, but doesn't seem to work.

Код:
using System;
using System.IO;

public class FileLength
{
    public static void Main()
    {
  
        DirectoryInfo di = new DirectoryInfo("{-Project.Directory}");
        // 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);
    }
}
I know little about C code so there's probably a lot wrong. But maybe somebody could point me in the right direction?
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Here's a sample
 

Вложения

  • Спасибо
Реакции: archel

archel

Client
Регистрация
02.05.2011
Сообщения
175
Благодарностей
22
Баллы
18
Nice. Thanks!
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)