Deleting Txt File Contents

I can Create,Delete,Read and Write to text files but how do I Delete the contents of a Text File…?

Thanks in Advance for any Help.

Using TextOutputStream.Create will create a new blank file, even if the file already exists.

you can open file with binary stream and set length property of stream to zero.
Than close and file is empty.

Thank You Very Much will give it a try.

While Christian is correct (as usual) I can’t think of any good reason for doing that with a text file. If you need new data, just Create a new file.

Remember to ask your user before deleting the contents of files.

Unless it’s a file meant for internal use, of course.

or you just wanna p*ss them off :smiley:

Uh oh, Dave’s twin brother Evil Dave just showed up…

Ok, enough is enough.

I need to clear the file as it is being used as a temporary store while working on blending the contents of two files and leaving the result in the original file.
I have taken the advice and just create a new file when I need to empty the file.

It all works fine now so thanks for the advice so thats the end of it.

'Ok, enough is enough.

I need to clear the file as it is being used as a temporary store while working on blending the contents of two files and leaving the result in the original file.
I have taken the advice and just create a new file when I need to empty the file.

It all works fine now so thanks for the advice so thats the end of it.

Sorry seems to have come up twice.

That’s not a good solution as it may cause Aliases to break. Also, apps that read from it won’t notice the change (unless you want that).

If you really want to erase an existing file, and keep it in existence, Christian’s solution with settings its Length to zero is the better way.

You could just mark an answer as “accepted” and then we all know that you’ve for your answer :wink:

[quote=92994:@Ian Cartwright]Ok, enough is enough.

[/quote]

Are you upset or something ?