matlab.unittest.diagnostics.FileArtifact class

Package: matlab.unittest.diagnostics

Artifact associated with a file on disk

Description

Use the FileArtifact class to reference files on disk and to copy the files to a new location conveniently.

Construction

artifact = FileArtifact(filename) creates an artifact associated with a particular file on disk.

Input Arguments

expand all

Name of file on disk, specified as a character vector or string scalar.

Example: "myFile.txt"

Properties

expand all

Artifact name, returned as a string scalar. For example, if the full path of a file artifact is "C:\Hello\World.txt", the value of Name would be "World.txt".

The parent folder where the artifact is located, returned as a string scalar.

Example: If the full path of a file artifact is "C:\Hello\World.txt", the value of Location is "C:\Hello".

The full path to the artifact, returned as a string scalar.

Example: "C:\Hello\World.txt"

Methods

copyToCopy artifacts to new location

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

Examples

collapse all

Create a file and write data to it.

filename = "MyFile.txt";
fileID = fopen(filename,'w');
fwrite(fileID,rand(5));
fclose(fileID);

Create a FileArtifact instance. In this example, the current working folder is "C:\work".

import matlab.unittest.diagnostics.FileArtifact;
artifact = FileArtifact(filename)
artifact = 

  FileArtifact with properties:

        Name: "MyFile.txt"
    Location: "C:\work\Desktop"
    FullPath: "C:\work\Desktop\MyFile.txt"
Introduced in R2017a