Options
All
  • Public
  • Public/Protected
  • All
Menu

Class File

Represents a File entity on the file system.

Hierarchy

Index

Properties

extension

extension: string

Gets the extension of the file.

isLocked

isLocked: boolean

Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.

lastModified

lastModified: Date

Gets the Date object specifying the last time this entity was modified.

name

name: string

Gets the name of the entity.

parent

parent: Folder

Gets the Folder object representing the parent of this entity. Will be null for a root folder like Documents or Temporary. This property is readonly.

path

path: string

Gets the fully-qualified path (including the extension for a File) of the entity.

size

size: number

Gets the size in bytes of the file.

Methods

read

  • read(): Promise<any>

readSync

  • readSync(onError?: function): any
  • Reads the binary content of the file synchronously.

    Parameters

    • Optional onError: function

      An optional function to be called if some IO-error occurs.

        • (error: any): any
        • Parameters

          • error: any

          Returns any

    Returns any

readText

  • readText(encoding?: string): Promise<string>
  • Reads the content of the file as a string using the specified encoding (defaults to UTF-8).

    Parameters

    • Optional encoding: string

      An optional value specifying the preferred encoding (defaults to UTF-8).

    Returns Promise<string>

readTextSync

  • readTextSync(onError?: function, encoding?: string): string
  • Reads the content of the file as a string synchronously, using the specified encoding (defaults to UTF-8).

    Parameters

    • Optional onError: function

      An optional function to be called if some IO-error occurs.

        • (error: any): any
        • Parameters

          • error: any

          Returns any

    • Optional encoding: string

      An optional value specifying the preferred encoding (defaults to UTF-8).

    Returns string

remove

  • remove(): Promise<any>

removeSync

  • removeSync(onError?: function): void

rename

  • rename(newName: string): Promise<any>

renameSync

  • renameSync(newName: string, onError?: function): void
  • Renames the current entity synchronously, using the specified name.

    Parameters

    • newName: string

      The new name to be applied to the entity.

    • Optional onError: function
        • (error: any): any
        • Parameters

          • error: any

          Returns any

    Returns void

write

  • write(content: any): Promise<void>
  • Writes the provided binary content to the file.

    Parameters

    • content: any

      The binary content to be saved to the file.

    Returns Promise<void>

writeSync

  • writeSync(content: any, onError?: function): void
  • Writes the provided binary content to the file synchronously.

    Parameters

    • content: any

      The binary content to be saved to the file.

    • Optional onError: function

      An optional function to be called if some IO-error occurs.

        • (error: any): any
        • Parameters

          • error: any

          Returns any

    Returns void

writeText

  • writeText(content: string, encoding?: string): Promise<any>
  • Writes the provided string to the file, using the specified encoding (defaults to UTF-8).

    Parameters

    • content: string

      The content to be saved to the file.

    • Optional encoding: string

      An optional value specifying the preferred encoding (defaults to UTF-8).

    Returns Promise<any>

writeTextSync

  • writeTextSync(content: string, onError?: function, encoding?: string): void
  • Writes the provided string to the file synchronously, using the specified encoding (defaults to UTF-8).

    Parameters

    • content: string

      The content to be saved to the file.

    • Optional onError: function

      An optional function to be called if some IO-error occurs.

        • (error: any): any
        • Parameters

          • error: any

          Returns any

    • Optional encoding: string

      An optional value specifying the preferred encoding (defaults to UTF-8).

    Returns void

Static exists

  • exists(path: string): boolean
  • Checks whether a File with the specified path already exists.

    Parameters

    • path: string

      The path to check for.

    Returns boolean

Static fromPath

  • fromPath(path: string): File

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method