LibraryEASYProcess Reference ManualProcessesServicesFileSystemWorkshopWriteFile

WriteFile Overview

WriteFile service writes the specified text data into the specified file. If the file does not exist, it will be created. If file already exists, it will be overwritten. We usually use WriteFile service to create .txt and .csv file. For .pdf file, please refer to HtmlStringToPDFStream service.

WriteFile Use Examples
FileNameThe full path of the file. You can also give a network path \\[Server Name]\[Directory]\[File Name] or a mapped folder path.

DataText data to be written to the file

InsertNewLineThere are three valid input values. Before - a new line is inserted before the Data. After - a new line is inserted after the Data. None or blank - no new line is inserted.

ExceptionIf the directory doesn't exists, service will throw an exception.
WrittenReturns True/False depending on whether the file was written successfully

WriteFile Use Example

Basic WriteFile Use

This is an example that we write a file specified text data. We first checked if the directory exists. If not, we will create a new directory before we write the file.

In EASYProcess, the service returns Written = True, which means it is created successfully.

In the target directory, you can see the file created with the data we wrote.

If the directory doesn’t exist and we don’t check it before using WriteFile service, EASYProcess will throw the following exception.

Use WriteFile to override existing file

In the previous example, we have created a file TextAttach.txt in the test directory. In this example, we call the service again with the same directory and file name.

There is only one file in that directory with the new text message after the service runs successfully.

Powered by EASYProcess (© 2022 K-Rise Systems, Inc).