Skip to content

Commit

Permalink
Change devlanguage (#44234)
Browse files Browse the repository at this point in the history
respond to internal feedback.

The code is VB, but it's labelled as C#.
  • Loading branch information
BillWagner authored Jan 17, 2025
1 parent 971f563 commit c6233f8
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "How to: Rename a File"
description: "Learn about how to rename a file with the Visual Basic Runtime Library or the .NET base class library."
ms.date: 07/20/2015
ms.date: 01/14/2025
helpviewer_keywords:
- "I/O [Visual Basic], renaming files"
- "files [Visual Basic], renaming"
Expand All @@ -17,15 +17,15 @@ The `System.IO.File` object doesn't contain a method to rename a file, instead,

The following example renames the file located in the `My Documents` folder from `TextFile.txt` to `NewName.txt`.

:::code language="csharp" source="./snippets/how-to-rename-a-file/Form1.vb" id="BCLRename":::
:::code language="vb" source="./snippets/how-to-rename-a-file/Form1.vb" id="BCLRename":::

## Rename with the Visual Basic run-time

Use the `RenameFile` method of the `My.Computer.FileSystem` object to rename a file by supplying the full path to the file and the new file name. This method can't be used to move a file to a different directory. To learn how to move a file, see [How to: Move a File in Visual Basic](how-to-move-a-file.md).

The following example renames the file located in the `My Documents` folder from `TextFile.txt` to `NewName.txt`.

:::code language="csharp" source="./snippets/how-to-rename-a-file/Form1.vb" id="MyRename":::
:::code language="vb" source="./snippets/how-to-rename-a-file/Form1.vb" id="MyRename":::

Visual Studio provides an IntelliSense code snippet that uses `My.Computer.FileSystem.RenameFile`. The snippet is located in **File system - Processing Drives, Folders, and Files**. For more information, see [Code Snippets](/visualstudio/ide/code-snippets).

Expand Down

0 comments on commit c6233f8

Please sign in to comment.