✨ Add folder via dialog
This commit is contained in:
@@ -24,7 +24,7 @@ public class IdeFileExternalChangeHandler
|
||||
var sharpIdeFolder = SolutionModel.AllFolders.SingleOrDefault(f => f.Path == folderPath);
|
||||
if (sharpIdeFolder is not null)
|
||||
{
|
||||
Console.WriteLine($"Error - Folder {folderPath} already exists");
|
||||
//Console.WriteLine($"Error - Folder {folderPath} already exists");
|
||||
return;
|
||||
}
|
||||
var containingFolderPath = Path.GetDirectoryName(folderPath)!;
|
||||
@@ -34,7 +34,8 @@ public class IdeFileExternalChangeHandler
|
||||
Console.WriteLine($"Error - Containing Folder of {folderPath} does not exist");
|
||||
return;
|
||||
}
|
||||
await _sharpIdeSolutionModificationService.CreateDirectory(containingFolder, folderPath);
|
||||
var folderName = Path.GetFileName(folderPath);
|
||||
await _sharpIdeSolutionModificationService.AddDirectory(containingFolder, folderName);
|
||||
}
|
||||
|
||||
private async Task OnFileCreated(string filePath)
|
||||
|
||||
@@ -6,9 +6,10 @@ public class IdeFileOperationsService(SharpIdeSolutionModificationService sharpI
|
||||
{
|
||||
private readonly SharpIdeSolutionModificationService _sharpIdeSolutionModificationService = sharpIdeSolutionModificationService;
|
||||
|
||||
public async Task CreateDirectory(SharpIdeFolder parentFolder, string directoryPath)
|
||||
public async Task CreateDirectory(SharpIdeFolder parentFolder, string newDirectoryName)
|
||||
{
|
||||
var newFolder = await _sharpIdeSolutionModificationService.CreateDirectory(parentFolder, directoryPath);
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
var newDirectoryPath = Path.Combine(parentFolder.Path, newDirectoryName);
|
||||
Directory.CreateDirectory(newDirectoryPath);
|
||||
var newFolder = await _sharpIdeSolutionModificationService.AddDirectory(parentFolder, newDirectoryName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ public class SharpIdeSolutionModificationService
|
||||
{
|
||||
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
||||
|
||||
public async Task<SharpIdeFolder> CreateDirectory(SharpIdeFolder parentFolder, string directoryPath)
|
||||
/// The directory must already exist on disk
|
||||
public async Task<SharpIdeFolder> AddDirectory(SharpIdeFolder parentFolder, string directoryName)
|
||||
{
|
||||
// Passing [] to allFiles and allFolders, as we assume that a brand new folder has no subfolders or files yet
|
||||
var sharpIdeFolder = new SharpIdeFolder(new DirectoryInfo(directoryPath), parentFolder, [], []);
|
||||
var addedDirectoryPath = Path.Combine(parentFolder.Path, directoryName);
|
||||
var sharpIdeFolder = new SharpIdeFolder(new DirectoryInfo(addedDirectoryPath), parentFolder, [], []);
|
||||
parentFolder.Folders.Add(sharpIdeFolder);
|
||||
SolutionModel.AllFolders.Add(sharpIdeFolder);
|
||||
return sharpIdeFolder;
|
||||
|
||||
Reference in New Issue
Block a user