Методы переименования файлов в C#

Чтобы переименовать файл в C#, вы можете использовать различные методы, предоставляемые пространством имен System.IO. Вот несколько вариантов:

  1. Использование метода File.Move:
    
    string oldFilePath = "path/to/old/file.ext";
    string newFilePath = "path/to/new/file.ext";

File.Move(oldFilePath, newFilePath);


2. Using `FileInfo.MoveTo` method:
```csharp
string oldFilePath = "path/to/old/file.ext";
string newFilePath = "path/to/new/file.ext";

FileInfo fileInfo = new FileInfo(oldFilePath);
fileInfo.MoveTo(newFilePath);
  1. Использование методов File.Copyи File.Delete:
    
    string oldFilePath = "path/to/old/file.ext";
    string newFilePath = "path/to/new/file.ext";

File.Copy(oldFilePath, newFilePath);
File.Delete(oldFilePath);


4. Using `Directory.Move` method to move and rename a file:
```csharp
string oldFilePath = "path/to/old/file.ext";
string newFilePath = "path/to/new/file.ext";

string newDirectoryPath = Path.GetDirectoryName(newFilePath);
Directory.CreateDirectory(newDirectoryPath);
Directory.Move(oldFilePath, newFilePath);

Не забудьте заменить "path/to/old/file.ext"и "path/to/new/file.ext"фактическими путями к файлам.