rename file from IDE

This commit is contained in:
Matt Parker
2025-10-22 18:22:03 +10:00
parent 588299ef39
commit 23ded1e6dd
5 changed files with 115 additions and 1 deletions

View File

@@ -87,6 +87,16 @@ public class IdeFileOperationsService(SharpIdeSolutionModificationService sharpI
return sharpIdeFile;
}
public async Task<SharpIdeFile> RenameFile(SharpIdeFile file, string newFileName)
{
var parentPath = Path.GetDirectoryName(file.Path)!;
var newFilePath = Path.Combine(parentPath, newFileName);
if (File.Exists(newFilePath)) throw new InvalidOperationException($"File {newFilePath} already exists.");
File.Move(file.Path, newFilePath);
var sharpIdeFile = await _sharpIdeSolutionModificationService.RenameFile(file, newFileName);
return sharpIdeFile;
}
public async Task<SharpIdeFile> MoveFile(IFolderOrProject destinationParentNode, SharpIdeFile fileToMove)
{
var newFilePath = Path.Combine(destinationParentNode.ChildNodeBasePath, fileToMove.Name);