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:
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.
File Writing: This involves automatically writing data to a file, such as writing the results of a calculation or extraction to a CSV file.
File Copy: This involves automatically copying a file from one location to another.
File Move: This involves automatically moving a file from one location to another.
File Delete: This involves automatically deleting a file.
File Rename: This involves automatically renaming a file.
File Compression: This involves automatically compressing a file into a ZIP archive.
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.
File.CreateFile("D:\\eras\\test.xlsx");
CreateDirectory
This method is used for creating directory.
Parameters
- path -
string= The directory name is written.
File.CreateDirectory("D:\\eras");
DeleteFile
This method is used for deleting file.
Parameters
- path -
string= The file name is written.
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
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.
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.
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.
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
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
var result = File.GetDirectories("D:\\eras\\", true);
GetFileContent
This method is used for getting file content.
Parameters
- sourceFile -
string= The folder name is written.
var result = File.GetFileContent("D:\\eras\\test.txt", true);