File Size

From SwiftAPI

Jump to: navigation, search

Contents

C#

using System.IO;
 
FileInfo fileInfo = new FileInfo("file.txt");
long size = fileInfo.Length;

Java

import java.io.File;
 
File file = new File("file.txt");
long size = file.length();

Objective-C

unsigned long long size = [[[NSFileManager defaultManager] attributesOfItemAtPath:@"file.txt" error:NULL] fileSize];

Perl

$size = -s 'file.txt';

PHP

php.net

$size = filesize('file.txt');

Python

import os
 
size = os.path.getsize('file.txt')

Ruby

size = File.size("file.txt")

Visual Basic .NET

Dim fileInfo As New IO.FileInfo("input.txt")
Dim size As Long = fileInfo.Length
Personal tools