Skip to main content
Modules

File Manager

File Manager

The File Manager module is responsible for performing file and folder handling actions. Its methods can be accessed as in the example below:

js
await FileManager.copy["v1_0_0"]({
pathFrom: 'C:/Users/Roberty/Desktop/teste.txt',
pathTo: 'C:/Users/Roberty/Desktop/teste2.txt',
})

Methods

copy

Method responsible for copying a file or folder with all of its files into another folder passed.

js
await FileManager.copy["v1_0_0"]({
pathFrom: 'C:/Users/Roberty/Desktop/teste.txt',
pathTo: 'C:/Users/Roberty/Desktop/teste2.txt',
})

Required parameters

  • pathFrom: String - expects a string with the path of the file or folder that will be copied.
  • pathTo: String - expects a string with the path of the file or folder where the copied file or folder will be pasted.

Optional parameters

  • overwrite: Boolean - expects a boolean value indicating whether the file or folder will be overwritten. If the value is false, files with the same name are not modified.

Return

This method has no return.

createFile

Method responsible for creating a file.

js
const path = await FileManager.createFile["v1_0_0"]({
fileName: 'teste.txt',
filePath: 'C:/Users/Roberty/Desktop/',
})

Required parameters

  • fileName: String - expects a string with the name of the file that will be created.
  • filePath: String - expects a string with the path of the file that will be created.

Optional parameters

This method has no optional parameters.

Return

The constant or variable created, such as the path of the example shown earlier, receives a string with the path of the file created.

createFolder

Method responsible for creating a folder.

js
await FileManager.createFolder["v1_0_0"]({
path: 'C:/Users/Roberty/Desktop/teste',
})

Required parameters

  • path: String - expects a string with the path of the folder that will be created. The last part of the path must be the folder name.

Optional parameters

This method has no optional parameters.

Return

This method has no return.

exists

Method responsible for checking whether a file or folder exists.

js
const exists = await FileManager.exists["v1_0_0"]({
pathFile: 'C:/Users/Roberty/Desktop/teste.txt',
})

Required parameters

  • pathFile: String - expects a string with the path of the file or folder that will be checked.

Optional parameters

This method has no optional parameters.

Return

The constant or variable created, such as the exists of the example shown earlier, receives a boolean value indicating whether the file or folder exists.

move

Method responsible for moving a file or folder with all of its files into another folder passed.

js
await FileManager.move["v1_0_0"]({
pathFrom: 'C:/Users/Roberty/Desktop/teste.txt',
pathTo: 'C:/Users/Roberty/Desktop/teste2.txt',
})

Required parameters

  • pathFrom: String - expects a string with the path of the file or folder that will be moved.
  • pathTo: String - expects a string with the path of the file or folder the files or folder will be moved to.

Optional parameters

  • overwrite: Boolean - expects a boolean value indicating whether the file or folder will be overwritten. If the value is false, files with the same name are not modified in the destination folder.

Return

This method has no return.

readFolder

Method responsible for reading the contents in a folder.

js
const files = await FileManager.readFolder["v1_0_0"]({
folderPath: 'C:/Users/Roberty/Desktop/teste',
})

Required parameters

  • folderPath: String - expects a string with the path of the folder that will be read.

Optional parameters

  • fullPath: Boolean - expects a boolean value indicating whether the full path will be returned. If the value is true, the full path of the files in the folder is returned; otherwise, only the file names are returned.
  • recursive: Boolean - expects a boolean value indicating whether the files in the subfolders of the path must also be returned. If the value is true, the files in the subfolders are returned; otherwise, only the files in the folder passed are returned.

Return

The constant or variable created, such as the files of the example shown earlier, receives an object that gives access to the following properties:

  • files.values: String[] - returns an array of strings with the names of all the files read.
  • files.count: Number - returns a number representing how many files were read.

readOnlyFolders

Method responsible for reading only the subfolders in a folder, ignoring files.

js
const folders = await FileManager.readOnlyFolders["v1_0_0"]({
folderPath: 'C:/Users/Roberty/Desktop/teste',
})

Required parameters

  • folderPath: String - expects a string with the path of the folder that will be read.

Optional parameters

  • recursive: Boolean - expects a boolean value indicating whether the nested subfolders will also be returned. Default value: false.
  • fullPath: Boolean - expects a boolean value indicating whether the full path of the folders will be returned. If false, it returns only the folder names. Default value: false.

Return

The constant or variable created, such as the folders of the example shown earlier, receives an object that gives access to the following properties:

  • folders.values: String[] - returns an array of strings with the names or paths of the folders found.
  • folders.count: Number - returns the number of folders found.

readTextFile

Method responsible for reading a text file.

js
const text = await FileManager.readTextFile["v1_0_0"]({
filePath: 'C:/Users/Roberty/Desktop/teste.txt',
})

Required parameters

  • filePath: String - expects a string with the path of the file that will be read.

Optional parameters

This method has no optional parameters.

Return

The constant or variable created, such as the text of the example shown earlier, receives a string with the content of the file read.

remove

Method responsible for removing a file or folder.

js
await FileManager.remove["v1_0_0"]({
path: 'C:/Users/Roberty/Desktop/teste.txt',
})

Required parameters

  • path: String - expects a string with the path of the file or folder that will be removed.

Optional parameters

This method has no optional parameters.

Return

This method has no return.

rename

Method responsible for renaming a file or folder.

js
await FileManager.rename["v1_0_0"]({
path: 'C:/Users/Roberty/Desktop/teste.txt',
newName: 'teste2.txt',
})

Required parameters

  • path: String - expects a string with the path of the file or folder that will be renamed.
  • newName: String - expects a string with the new name of the file or folder.

Optional parameters

This method has no optional parameters.

Return

This method has no return.

writeFile

Method responsible for writing into a text file. If this file has content, the content is completely replaced.

js
await FileManager.writeFile["v1_0_0"]({
filePath: 'C:/Users/Roberty/Desktop/teste.txt',
content: 'Hellow World!',
})

Required parameters

  • filePath: String - expects a string with the path of the file that will be written.
  • content: String - expects a string with the content that will be written into the file.

Optional parameters

This method has no optional parameters.

Return

This method has no return.

zip

Method responsible for compressing files or a folder into a .zip file.

js
await FileManager.zip["v1_0_0"]({
pathFileZip: `C:/Users/Roberty/Desktop/arquivo.zip`,
pathsToZip: [`C:/Users/Roberty/Desktop/arquivo1.txt`, `C:/Users/Roberty/Desktop/arquivo2.xlsx`]
})

Required parameters

  • pathFileZip: String - expects a string with the path of the zip file that will be created.
  • pathsToZip: String[] - expects an array of strings with the path of every file that will be compressed.

Optional parameters

This method has no optional parameters.

Return

This method has no return.

unZip

Method responsible for unzipping a .zip file.

js
await FileManager.unZip["v1_0_0"]({
pathFileUnzip: `C:/Users/Roberty/Desktop`,
pathZippedFile: `C:/Users/Roberty/Desktop/arquivo.zip`
})

Required parameters

  • pathFileUnzip: String - expects a string with the path of the folder where the files will be unzipped.
  • pathZippedFile: String - expects a string with the path of the .zip file that will be unzipped.

Optional parameters

This method has no optional parameters.

Return

This method has no return.