Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic
 RenameFile Method (My.Computer.File...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Basic Language Reference
My.Computer.FileSystem.RenameFile Method

Renames a file.

' Usage
My.Computer.FileSystem.RenameFile(file ,newName)
' Declaration
Public Sub RenameFile( _
   ByVal file As String, _
   ByVal newName As String _
)
file

String. File to be renamed. Required.

newName

String. New name of file. Required.

The following conditions may cause an exception:

This method cannot be used to move a file; use the My.Computer.FileSystem.MoveFile Method to move and rename the file.

The following table lists an example of a task involving the My.Computer.FileSystem.RenameFile method.

This example renames the file Test.txt to SecondTest.txt.

Visual Basic
My.Computer.FileSystem.RenameFile("C:\Test.txt", "SecondTest.txt")

Change "C:\Test.txt" to the path and file name of the file that you want to rename.

Namespace: Microsoft.VisualBasic.MyServices

Class: FileSystemProxy (provides access to FileSystem)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type

Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

The following permission may be necessary:

Permission

Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker