Create text file of folder structure via EditorScript

[MenuItem(“Assets/AssetBundle/StandaloneWindows”)]
static void ExportBundleStandaloneWindows()
{
//Windowws
string bundlePathWin = _remotePath + “StandaloneWindows”;
if (!Directory.Exists(bundlePathWin))
Directory.CreateDirectory(bundlePathWin);
BuildPipeline.BuildAssetBundles(bundlePathWin, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
}

so this script is creating the assetbundle i need. All working. Is it possible to create a .txt-file or a .json in the same method to list content of given directory? I’ve literally searched the whole web for it. I’ve tried everything and either I’m just not advanced enough to get it or I’m missing some vital information.

The following example will create a text file in the bundlePathWin (from your example below) with the list of files existing in that folder:

MenuItem("Assets/AssetBundle/Index/StandaloneWindows")]
static void ExportBundleStandaloneWindowsIndex()
{
    string bundlePathWin = _remotePath + "StandaloneWindows";
    string folderContent = "";
    if (Directory.Exists(bundlePathWin))
    {
        var allFiles = Directory.GetFiles(bundlePathWin, "", SearchOption.AllDirectories);
        foreach (string filePath in allFiles)
        {
            // Skip the index file
            if (filePath.EndsWith("all_content.txt"))
                folderContent += filePath + "

";
}
}
string contentFilepath = Path.Combine(bundlePathWin, “all_content.txt”);
File.WriteAllText(folderContent);
}