Joutsen  v0.4.1
Public Member Functions | Properties | List of all members
Joutsen.System.IO.File Interface Reference

Public Member Functions

void Create ()
 Creates the file without content. More...
 
void Create (SystemIO.Stream contents)
 Creates the file with content. More...
 
SystemIO.Stream CreateAndOpen ()
 Creates the file on the filesystem and opens it for writing. More...
 
SystemIO.Stream Open (SystemIO.FileMode mode)
 Opens the file for reading or writing. More...
 
File CopyTo (string dstPath, bool overwrite=false)
 Copies the file to a different path. More...
 
File CopyTo (FilesystemPath dstPath, bool overwrite=false)
 Copies the file to a different path. More...
 
File MoveTo (string dstPath)
 Moves the file to a different location. More...
 
File MoveTo (FilesystemPath dstPath)
 Moves the file to a different location. More...
 
void Delete ()
 Deletes the file on from the filesystem. More...
 
File Replace (string dstPath, string backupPath)
 Replaces the file at dstPath with this file creating a backup in backupPath. More...
 
File Replace (FilesystemPath dstPath, FilesystemPath backupPath)
 Replaces the file at dstPath with this file creating a backup in backupPath. More...
 
File Replace (File dstFile, File backup)
 Replaces the file at dstFile with this file creating a backup in backup. More...
 
File ReplaceWith (string srcPath, string backupPath)
 Replace this file's content with the content of the file at . More...
 
File ReplaceWith (FilesystemPath srcPath, FilesystemPath backupPath)
 Replace this file's content with the content of the file at . More...
 
File ReplaceWith (File srcFile, File backup)
 Replace this file's content with the content of srcFile. More...
 

Properties

String Name [get]
 
String Extension [get]
 The extension of the file. More...
 
FilesystemPath Path [get]
 The path of the file. More...
 
Folder Folder [get]
 The folder where the file is located. More...
 
DateTime LastModificationTime [get]
 The time the file was last changed. More...
 
DateTime CreationTime [get]
 The time the file was created. More...
 
bool Exists [get]
 Checks if the file exists in the filesystem. More...
 
bool IsWritable [get]
 Checks if the file is writable in the filesystem. More...
 

Member Function Documentation

◆ CopyTo() [1/2]

File Joutsen.System.IO.File.CopyTo ( string  dstPath,
bool  overwrite = false 
)

Copies the file to a different path.

Parameters
dstPaththe path to copy the file to
overwritedetermines if an existing file at dstPath should be overwritten
Returns
the file representing the copy

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ CopyTo() [2/2]

File Joutsen.System.IO.File.CopyTo ( FilesystemPath  dstPath,
bool  overwrite = false 
)

Copies the file to a different path.

Parameters
dstPaththe path to copy the file to
overwritedetermines if an existing file at dstPath should be overwritten
Returns
the file representing the copy
Exceptions
System.ArgumentNullExceptionif dstPath is null

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ Create() [1/2]

void Joutsen.System.IO.File.Create ( )

Creates the file without content.

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ Create() [2/2]

void Joutsen.System.IO.File.Create ( SystemIO.Stream  contents)

Creates the file with content.

Parameters
contentthe content that should be written to the new file

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ CreateAndOpen()

SystemIO.Stream Joutsen.System.IO.File.CreateAndOpen ( )

Creates the file on the filesystem and opens it for writing.

Returns
the open stream which can be used to write to the file
Remarks
The caller has to take care of closing the stream.

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ Delete()

void Joutsen.System.IO.File.Delete ( )

Deletes the file on from the filesystem.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ MoveTo() [1/2]

File Joutsen.System.IO.File.MoveTo ( string  dstPath)

Moves the file to a different location.

Parameters
dstPaththe path to move the file to
Returns
the file representing the moved file

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ MoveTo() [2/2]

File Joutsen.System.IO.File.MoveTo ( FilesystemPath  dstPath)

Moves the file to a different location.

Parameters
dstPaththe path to move the file to
Returns
the file representing the moved file
Exceptions
System.ArgumentNullExceptionif dstPath is null

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ Open()

SystemIO.Stream Joutsen.System.IO.File.Open ( SystemIO.FileMode  mode)

Opens the file for reading or writing.

Parameters
modedetermines if the file is opened for reading or writing
Returns
a stream representing the files content
Remarks
The stream is not closed automatically. The caller needs to take care of properly closing it.

Implemented in Joutsen.System.IO.TemporaryFile, and Joutsen.System.IO.LocalFile.

◆ Replace() [1/3]

File Joutsen.System.IO.File.Replace ( string  dstPath,
string  backupPath 
)

Replaces the file at dstPath with this file creating a backup in backupPath.

Parameters
dstpaththe path to the file that should be replaced
backupPaththe path to the location where the backup of the file at dstPath should be stored
Returns
a file representing the backup of the replaced file or null if no backup is created
Remarks
If null is passed as backupPath, no backup is created. The original file is deleted by this method.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ Replace() [2/3]

File Joutsen.System.IO.File.Replace ( FilesystemPath  dstPath,
FilesystemPath  backupPath 
)

Replaces the file at dstPath with this file creating a backup in backupPath.

Parameters
dstpaththe path to the file that should be replaced
backupPaththe path to the location where the backup of the file at dstPath should be stored
Returns
a file representing the backup of the replaced file or null if no backup is created
Exceptions
System.ArgumentNullExceptionif dstPath is null
Remarks
If null is passed as backupPath, no backup is created. The original file is deleted by this method.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ Replace() [3/3]

File Joutsen.System.IO.File.Replace ( File  dstFile,
File  backup 
)

Replaces the file at dstFile with this file creating a backup in backup.

Parameters
dstFilethe file that should be replaced
backupthe file where the backup of dstFile should be stored
Returns
a file representing the backup of the replaced file or null if no backup is created
Exceptions
System.ArgumentNullExceptionif dstFile is null
Remarks
If null is passed as backup, no backup is created.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ ReplaceWith() [1/3]

File Joutsen.System.IO.File.ReplaceWith ( string  srcPath,
string  backupPath 
)

Replace this file's content with the content of the file at .

Parameters
srcPaththe path to the file that contains the content which should replace this file
backupthe file where the backup of this file should be stored
Returns
a file representing the backup of this file or null if no backup is created
Exceptions
System.ArgumentNullExceptionif srcFile is null
Remarks
If null is passed as backup, no backup is created.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ ReplaceWith() [2/3]

File Joutsen.System.IO.File.ReplaceWith ( FilesystemPath  srcPath,
FilesystemPath  backupPath 
)

Replace this file's content with the content of the file at .

Parameters
srcPaththe path to the file that contains the content which should replace this file
backupthe file where the backup of this file should be stored
Returns
a file representing the backup of this file or null if no backup is created
Exceptions
System.ArgumentNullExceptionif srcFile is null
Remarks
If null is passed as backup, no backup is created.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

◆ ReplaceWith() [3/3]

File Joutsen.System.IO.File.ReplaceWith ( File  srcFile,
File  backup 
)

Replace this file's content with the content of srcFile.

Parameters
srcFilethe file that contains the content which should replace this file
backupthe file where the backup of this file should be stored
Returns
a file representing the backup of this file or null if no backup is created
Exceptions
System.ArgumentNullExceptionif srcFile is null
Remarks
If null is passed as backup, no backup is created.

Implemented in Joutsen.System.IO.LocalFile, and Joutsen.System.IO.TemporaryFile.

Property Documentation

◆ CreationTime

DateTime Joutsen.System.IO.File.CreationTime
get

The time the file was created.

◆ Exists

bool Joutsen.System.IO.File.Exists
get

Checks if the file exists in the filesystem.

◆ Extension

String Joutsen.System.IO.File.Extension
get

The extension of the file.

◆ Folder

Folder Joutsen.System.IO.File.Folder
get

The folder where the file is located.

◆ IsWritable

bool Joutsen.System.IO.File.IsWritable
get

Checks if the file is writable in the filesystem.

◆ LastModificationTime

DateTime Joutsen.System.IO.File.LastModificationTime
get

The time the file was last changed.

◆ Name

String Joutsen.System.IO.File.Name
get

◆ Path

FilesystemPath Joutsen.System.IO.File.Path
get

The path of the file.