Skip to content

Commit

Permalink
Added file rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
EGSP committed Dec 23, 2022
1 parent 5c7f168 commit 407a223
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Automata/IO/FileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ public static FileStream Stream(this IFile file)
{
return new FileStream(file.Path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
}

public static IFile Rename(this IFile file, string newNameWithoutExtension)
{
var ext = file.Extension();
var oldPath = file.Path;
var newFile = file.Directory.File(newNameWithoutExtension + ext);
IOShared.FileSystem.File.Move(oldPath, newFile.Path);
return newFile;
}
}

0 comments on commit 407a223

Please sign in to comment.