Skip to content

Modern Fs File Close

Paul Squires edited this page Oct 22, 2026 · 3 revisions

Home › Filesystem › File Streams › File.Close

File.Close

Closes the file and reports any error the close itself raised.

Syntax

File.Close( )

Notes

  • Closes the handle and reports the close's own error, which is where a network filesystem reports a write that failed late. The destructor closes too, but has nowhere to report an error.
  • The handle is gone afterwards either way. Closing a closed File is Ok.

Examples

#import "std/fs"
using fs

dim as ustring dir_ = CreateTempDir( "tkdoc" ).Value( )
dim as ustring p = PathJoin( dir_, "f.txt" )
dim as File f
f.Create( p )
print f.Close( ).IsOk( ), f.IsOpen( )    '' true false
print f.Close( ).IsOk( )               '' true

RemoveDirAll( dir_ )

Library: Filesystem Library Category: File Streams Documented under: Files

Clone this wiki locally