Main Content

addFolderIncludingChildFiles

フォルダーと子ファイルをプロジェクトに追加

説明

addFolderIncludingChildFiles(proj,folder) は、指定されたプロジェクトにフォルダー、すべてのサブフォルダー、およびファイルを追加します。サブフォルダーやファイルを追加せずに、指定されたフォルダーのみを追加するには、代わりに addFile を使用します。

newfile = addFolderIncludingChildFiles(proj,folder) は、追加されたファイルの ProjectFile オブジェクトを返します。

すべて折りたたむ

プロジェクト Times Table App を開きます。currentProject を使用して、現在読み込まれているプロジェクトからプロジェクト オブジェクトを作成します。

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

プロジェクト フォルダーに新規の親フォルダーを作成します。

newFolderPath = fullfile(proj.RootFolder, "newFolder");
mkdir(newFolderPath);

親フォルダーに新規サブフォルダーを作成します。

newSubFolderPath = fullfile(newFolderPath, "newSubFolder");
mkdir(newSubFolderPath);

サブフォルダーに新規ファイルを作成します。

filepath = fullfile(newSubFolderPath, "newVariables.mat");
save(filepath)

親フォルダー、サブフォルダー、ファイルをプロジェクトに追加します。サブフォルダー内のファイルが正しく追加されたことを確認します。

projectFile = addFolderIncludingChildFiles(proj, newFolderPath);
findFile(proj,"newFolder/newSubFolder/newVariables.mat")
ans = 

  ProjectFile with properties:

               Path: "C:\myProjects\examples\TimesTableApp\newFolder\newSubFolder\newVariables.mat"
             Labels: [1×1 matlab.project.Label]
           Revision: ""
    SourceControlStatus: Added

入力引数

すべて折りたたむ

プロジェクト。matlab.project.Project オブジェクトとして指定します。currentProject を使用して、現在読み込まれているプロジェクトからプロジェクト オブジェクトを作成します。

プロジェクトに追加するフォルダーのパス。文字ベクトルまたは string スカラーとして指定します。プロジェクト ルート フォルダーに対して相対的なパスを指定します。指定されたフォルダーはプロジェクト ルート フォルダー内になければなりません。

バージョン履歴

R2019a で導入