Get file size of file.

  • Автор темы Автор темы archel
  • Дата начала Дата начала

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?
 
Here's a sample
 

Вложения

  • Спасибо
Реакции: archel
Nice. Thanks!
 

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