Skip to main content

File Driver in Eras

File operations refer to various tasks that can be performed on files, such as reading, writing, copying, and deleting. In the context of RPA (Robotic Process Automation), file operations are used to automate tasks that involve file manipulation.

Here are some common file operations in RPA:

  1. File Reading: This involves automatically reading the contents of a file, such as a text file, spreadsheet, or XML file, into the RPA system for processing.

  2. File Writing: This involves automatically writing data to a file, such as writing the results of a calculation or extraction to a CSV file.

  3. File Copy: This involves automatically copying a file from one location to another.

  4. File Move: This involves automatically moving a file from one location to another.

  5. File Delete: This involves automatically deleting a file.

  6. File Rename: This involves automatically renaming a file.

  7. File Compression: This involves automatically compressing a file into a ZIP archive.

  8. File Decompression: This involves automatically decompressing a ZIP archive into its constituent files.

CreateFile​

This method is used for creating a new file.

Parameters

  • path - string = The file path is written.
How to use
File.CreateFile("D:\\eras\\test.xlsx");

CreateDirectory​

This method is used for creating directory.

Parameters

  • path - string = The directory name is written.
How to use
File.CreateDirectory("D:\\eras");

DeleteFile​

This method is used for deleting file.

Parameters

  • path - string = The file name is written.
How to use
File.DeleteFile("D:\\eras\\test.png");

DeleteDirectory​

This method is used for folder.

Parameters

  • path - string = The file name or the folder name is written.
  • recursively - bool = delete inner folders
How to use
File.DeleteDirectory("D:\\eras", true);

PathExists​

This method is used for giving the information that the file exists or does not exist in the given directory.

Parameters

  • path - string = The file path or directory is written.
How to use
var result = File.PathExists("D:\\eras");

CopyFile​

This method is used for copying file or folder.

Parameters

  • sourceFile - string = The file name or the folder name is written.
  • destinationFile - string = The destination directory for the copied files or folders is written.
  • overWrite - bool = Overwrite if there is a file or folder with same name.
How to use
var result = File.PathExists("D:\\eras\\test.xlsx", "C:\\Test", true);

MoveFile​

This method is used for moving files and folders to the desired directory.

Parameters

  • sourceFile - string = The file name or the folder name is written.
  • destinationFile - string = The destination directory for the copied files or folders is written.
  • overWrite - bool = Overwrite if there is a file or folder with same name.
How to use
var result = File.MoveFile("D:\\eras\\test.xlsx", "C:\\Test", true);

GetFiles​

This method is used for listing file names in folder.

Parameters

  • sourceFile - string = The file name is written.
  • recurseSubdirectories - bool = Get inner file names
How to use
var result = File.GetFiles("D:\\eras\\", true);

GetDirectories​

This method is used for listing folder names in folder.

Parameters

  • sourceFile - string = The folder name is written.
  • recurseSubdirectories - bool = Get inner folder names
How to use
var result = File.GetDirectories("D:\\eras\\", true);

GetFileContent​

This method is used for getting file content.

Parameters

  • sourceFile - string = The folder name is written.
How to use
var result = File.GetFileContent("D:\\eras\\test.txt", true);