Frends.File
Warning: Legacy tasks, see readme. FRENDS Tasks to preform various file system based operations such as: Reading, Writing, Copying, Deleting, Moving etc. on Windows based file systems.
Install / Use
/learn @FrendsPlatform/Frends.FileREADME
[!WARNING] Legacy tasks — do not use in new projects. The tasks in this repository are part of Frends legacy task library. For current, supported tasks visit tasks.frends.com.
Frends.File
FRENDS Tasks to preform various file system based operations.
Installing
You can install the task via FRENDS UI Task view, by searching for packages. You can also download the latest NuGet package from https://www.myget.org/feed/frends/package/nuget/Frends.File and import it manually via the Task view.
Documentation
Pattern matching
Find, Move and Delete tasks use pattern matching for finding files.
The search starts from the root directory defined in the input parameters.
* to match one or more characters in a path segment
** to match any number of path segments, including none
Examples:
**\output\*\temp\*.txt matches:
test\subfolder\output\2015\temp\file.txtproduction\output\2016\temp\example.txt
**\temp* matches
prod\test\temp123.xmltest\temp234.xml
subfolder\**\temp\*.xml matches
subfolder\temp\test.xmlsubfolder\foo\bar\is\here\temp\test.xml
Tasks
Read
File.Read task reads the string contents of one file.
Input:
| Property | Type | Description | Example |
|-----------------|----------|----------------------------------|-------------------------------------|
| Path | string | Full path to the file to be read.| c:\temp\foo.txt c:/temp/foo.txt |
Options:
| Property | Type | Description | Example |
|---------------------------------------------|----------------|------------------------------------------------|---------------------------|
| UseGivenUserCredentialsForRemoteConnections | bool | If set, allows you to give the user credentials to use to read files on remote hosts. If not set, the agent service user credentials will be used. Note: For deleting directories on the local machine, the agent service user credentials will always be used, even if this option is set.| |
| UserName | string | Needs to be of format domain\username | example\Admin |
| Password | string | | |
| FileEncoding | Enum | Encoding for the read content. By selecting 'Other' you can use any encoding. | |
| EncodingInString | string | The name of encoding to use. Required if the FileEncoding choice is 'Other'. A partial list of supported encoding names: https://msdn.microsoft.com/en-us/library/system.text.encoding.getencodings(v=vs.110).aspx | iso-8859-1 |
Result:
| Property | Type | Description | |-----------------|----------|-----------------------------| | Content | string | | | Path | string | Full path for the read file | | SizeInMegaBytes | double | | | CreationTime | DateTime | | | LastWriteTime | DateTime | |
ReadBytes
File.ReadBytes task reads contents of a file as a byte array.
Input:
| Property | Type | Description | Example |
|-----------------|----------|-----------------------------------|---------------------------------------|
| Path | string | Full path to the file to be read. | c:\temp\img1.png c:/temp/img2.png |
Options:
| Property | Type | Description | Example |
|---------------------------------------------|----------------|------------------------------------------------|---------------------------|
| UseGivenUserCredentialsForRemoteConnections | bool | If set, allows you to give the user credentials to use to read files on remote hosts. If not set, the agent service user credentials will be used. Note: For deleting directories on the local machine, the agent service user credentials will always be used, even if this option is set.| |
| UserName | string | Needs to be of format domain\username | example\Admin |
| Password | string | | |
Result:
| Property | Type | Description | |-----------------|----------|-----------------------------| | ContentBytes | byte[] | | | Path | string | Full path for the read file | | SizeInMegaBytes | double | | | CreationTime | DateTime | | | LastWriteTime | DateTime | |
Write
File.Write task writes string content to a file.
Input:
| Property | Type | Description | Example |
|-----------------|----------|------------------------------|---------------------------|
| Path | string | Full path to the file to be written to. | c:\temp\foo.txt c:/temp/foo.txt |
| Content | string | | |
Options:
| Property | Type | Description | Example |
|---------------------------------------------|----------------|------------------------------------------------|---------------------------|
| UseGivenUserCredentialsForRemoteConnections | bool | If set, allows you to give the user credentials to use to write files on remote hosts. If not set, the agent service user credentials will be used. Note: For deleting directories on the local machine, the agent service user credentials will always be used, even if this option is set.| |
| UserName | string | Needs to be of format domain\username | example\Admin |
| Password | string | | |
| FileEncoding | Enum | Encoding for the content. By selecting 'Other' you can use any encoding. | |
| EncodingInString | string | This should be filled if the FileEncoding choice is 'Other' A partial list of possible encodings: https://en.wikipedia.org/wiki/Windows_code_page#List | iso-8859-1 |
| EnableBom | bool | Visible if UTF-8 is used as the option for FileEncoding. | |
| WriteBehaviour | Enum{Append,Overwrite,Throw} | Determines how the File.Write works when the destination file already exists | |
Result:
| Property | Type | Description | |-----------------|--------|-----------------------------| | Path | string | Full path to the written file | | SizeInMegaBytes | double | |
WriteBytes
File.WriteBytes task writes a byte array to a file.
Input:
| Property | Type | Description | Example |
|-----------------|----------|-----------------------------------------|-------------------------------------|
| Path | string | Full path to the file to be written to. | c:\temp\img.png c:/temp/img.png |
| ContentBytes | byte[] | | |
Options:
| Property | Type | Description | Example |
|---------------------------------------------|----------------|------------------------------------------------|---------------------------|
| UseGivenUserCredentialsForRemoteConnections | bool | If set, allows you to give the user credentials to use to write files on remote hosts. If not set, the agent service user credentials will be used. Note: For deleting directories on the local machine, the agent service user credentials will always be used, even if this option is set.| |
| UserName | string | Needs to be of format domain\username | example\Admin |
| Password | string | | |
| WriteBehaviour | Enum{Append,Overwrite,Throw} | Determines how the File.Write works when the destination file already exists | |
Result:
| Property | Type | Description | |-----------------|--------|-------------------------------| | Path | string | Full path to the written file | | SizeInMegaBytes | double | |
Find
File.Find task is used for finding detailed information about multiple- or a single file. The task uses pattern matching for finding files.
Input:
| Property | Type | Description | Example |
|-----------------|----------|-------------------------------------|-------------------------|
| Directory | string | Root folder where the search starts.| c:\root\folder |
| Pattern | string | Pattern to match for files. | `
