Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isfile

Determine if input is file

Syntax

result = isfile(fileName)

Description

result = isfile(fileName) returns 1 if fileName is a file located on the specified path or in the current folder. Otherwise, isfile returns 0.

Examples

collapse all

Check if the input myfile1.txt is a file. A result of 1 indicates that myfile1.txt is a file.

result = isfile('myfile1.txt')
result = logical
   1

Create the folder myfolder, then check if myfolder is a file. A result of 0 indicates that myfolder is not a file.

mkdir myfolder;
result = isfile('myfolder')
result = logical
   0

Check if the inputs myfile1.txt and myfolder are files. A result of [1 0] indicates that myfile1.txt is a file and myfolder is not a file.

result = isfile(["myfile1.txt", "myfolder"])
result = 1×2 logical array
   1   0

Input Arguments

collapse all

File name, specified as a string array, character vector, or cell array of character vectors. fileName can include a relative path, but the relative path must be in the current folder. Otherwise, fileName must include a full path.

Data Types: string | cell | char

See Also

| |

Introduced in R2017b

Was this topic helpful?