[Newbies] RE: Determining File Size
van.upboy at gmail.com
Sun Mar 21 08:22:46 UTC 2010
Subbu, thanks for the hint to look for the directoryEntry.
I have working code (see example).
When I inspect aFile then the other variables are there (for instance, there
is a creationTime which contains a number, and there is a fileSize).
But the fileSize = 0.
1. What is going wrong with the fileSize, because the file is much bigger
2. How can I change creationTime to something readable? Now it is a
LargePositiveInteger, not very useful to display.
| aFileDir aFile |
aFileDir := (FileDirectory default directoryNamed: 'mytestdir').
aFile := aFileDir directoryEntryFor: 'my test file.mp3'.
Transcript cr;show: aFile creationTime printString.
Transcript cr;show: aFile fileSize printString.
> I'm listing files in a directory, but I want to show more than just the
> filename (like file size and may be creation date). I've searched for some
> time on the Internet, but I can't find the answer. How to do this?
> I've tried this:
> aFile := (FileDirectory default directoryNamed: directoryName)
> readOnlyFileNamed: 'testfile.pdf'.
> and then tried: aFile size but that doesn't seem to work.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> Message: 5
> Date: Sat, 20 Mar 2010 21:11:59 +0530
> From: "K. K. Subramaniam" <subbukk at gmail.com>
> Subject: Re: [Newbies] determining file size?
> To: beginners at lists.squeakfoundation.org
> Cc: Van Upboy <van.upboy at gmail.com>
> Message-ID: <201003202111.59879.subbukk at gmail.com>
> Content-Type: Text/Plain; charset="iso-8859-15"
> On Saturday 20 March 2010 09:02:32 pm Van Upboy wrote:
> > I'm listing files in a directory, but I want to show more than just the
> > filename (like file size and may be creation date). I've searched for
> > time on the Internet, but I can't find the answer. How to do this?
> File size is an attribute of the file's entry in its directory.
> See fileSize method in DirectoryEntry class. If you already have a file
> or a stream opened on it, use directoryEntry method. E.g.
> stream directoryEntry fileSize
> HTH .. Subbu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners