abalonpe at ulb.ac.be
Mon Nov 29 21:20:31 UTC 2010
Thank you very much for your help.
The thing is that, when I first got the exception, I deleted the
file manually in the Pharo folder so I'm pretty sure it doesn't exist.
Maybe that when I do: "aStream := FileStream newFileNamed:filename" Pharo
looks everywhere in my computer than it might find a file named 'test' or
with a part of it named which is 'test'...but the file was created in the
Pharo folder so I assume it must look only there to find a file, no?
2010/11/28 Levente Uzonyi <leves at elte.hu>
> On Sat, 27 Nov 2010, alexandre bp wrote:
>> I'm having trouble with the FileStream....
>> I have tried several things:
>> filename := 'test'.
>> aStream := StandardFileStream new.
>> 1) aStream := FileStream newFileNamed:filename.
>> 2) aStream := filename asFilename writeStream.
>> 1) this solution worked one time but when I tried to create other
>> files with other names (whatever the name) I get an exception:
>> 2) doesn't work at all. I get an exception as well:
>> MessageNotUnderstood: ByteString>>asFilename.
> How to use FileStreams?
> existingReadOnlyFile := FileStream readOnlyFileNamed: 'foo'. "raises an
> exception if the file doesn't exist"
> existingReadableAndWriteableFile := FileStream oldFileNamed: 'foo'. "raises
> an exception if the file doesn't exist"
> readableAndWriteableFile := FileStream fileNamed: 'foo'. "automatically
> creates the file if it doesn't exist"
> newReadableAndWriteableFile := FileStream newFileNamed: 'foo'. "raises an
> exception if the file exists"
> newReadableAndWriteableFile := FileStream forceNewFileNamed: 'foo'.
> "deletes the file if it exists"
> All of these methods have a do: variant. For example:
> FileStream readOnlyFileNamed: 'foo' do: [ :file | file contents "This will
> close the file and return it's contents." ].
> When to use StandardFileStream?
> Only when you don't need character encoding or line-end conversion.
>> I don't know what to do.... I don't understand why I have the
>> exception FileExistsException even thought the name I give to filename
>> is different...
> Are you sure that the file doesn't exist? Some systems (windows and most
> macs) are case insensitive, so if you have a file named 'TEST', then you
> also have 'test' and 'Test', etc.
>> Thx for your help
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
> seaside mailing list
> seaside at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the seaside