Thank you very much for your help.<div>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.</div><meta charset="utf-8"><meta charset="utf-8"><div>
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?</div>
<div>alex</div><meta charset="utf-8"><div><br><br><div class="gmail_quote">2010/11/28 Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@elte.hu">leves@elte.hu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sat, 27 Nov 2010, alexandre bp wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I'm having trouble with the FileStream....<br>
<br>
I have tried several things:<br>
filename := 'test'.<br>
aStream := StandardFileStream new.<br>
1) aStream := FileStream newFileNamed:filename.<br>
2) aStream := filename asFilename writeStream.<br>
<br>
1) this solution worked one time but when I tried to create other<br>
files with other names (whatever the name) I get an exception:<br>
FileExistsException<br>
2) doesn't work at all. I get an exception as well:<br>
MessageNotUnderstood: ByteString>>asFilename.<br>
</blockquote>
<br></div>
How to use FileStreams?<br>
<br>
existingReadOnlyFile := FileStream readOnlyFileNamed: 'foo'. "raises an exception if the file doesn't exist"<br>
existingReadableAndWriteableFile := FileStream oldFileNamed: 'foo'. "raises an exception if the file doesn't exist"<br>
readableAndWriteableFile := FileStream fileNamed: 'foo'. "automatically creates the file if it doesn't exist"<br>
newReadableAndWriteableFile := FileStream newFileNamed: 'foo'. "raises an exception if the file exists"<br>
newReadableAndWriteableFile := FileStream forceNewFileNamed: 'foo'. "deletes the file if it exists"<br>
<br>
All of these methods have a do: variant. For example:<br>
FileStream readOnlyFileNamed: 'foo' do: [ :file | file contents "This will close the file and return it's contents." ].<br>
<br>
When to use StandardFileStream?<br>
Only when you don't need character encoding or line-end conversion.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I don't know what to do.... I don't understand why I have the<br>
exception FileExistsException even thought the name I give to filename<br>
is different...<br>
</blockquote>
<br></div>
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.<br>
<br>
<br>
Levente<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
Thx for your help<br>
<br>
alex<br></div>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
<br>
</blockquote>
_______________________________________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org" target="_blank">seaside@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" target="_blank">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
</blockquote></div><br></div>