Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rename a File

2 views
Skip to first unread message

BIG555

unread,
Jan 13, 2003, 11:59:47 AM1/13/03
to
Hello: Can anyone tell me how to rename a file via VB.Net
programmatically??

I cannot find any method to do so in the File or FileInfo or any other
System.IO classes...

I did find the Rename function but is there any object based method
available?

Thanx,
Shannon Richards
BBA, AIT, MCP


Stephen Martin

unread,
Jan 13, 2003, 12:39:30 PM1/13/03
to
You need to use the File.Move or FileInfo.MoveTo methods. These are used to
rename a file or move it to a different directory/volume depending on the
arguments.

"BIG555" <sricha...@hotmail.com> wrote in message
news:u#E2hWyuCHA.2592@TK2MSFTNGP10...

MSNEWS

unread,
Jan 13, 2003, 3:04:24 PM1/13/03
to
Try this:

Dim objFile As System.IO.File

Dim strSource As String = "C:\text.txt"

Dim strDest As String = "C:\text_new.txt"

If objFile.Exists(strSource) = True And objFile.Exists(strDest) =
False Then

objFile.Move(strSource, strDest)

End If

Todd A.

"Stephen Martin" <sma...@removethis.emsoft.andthis.ca> wrote in message
news:Orl6vqyuCHA.2280@TK2MSFTNGP11...

Mark Bower [MSFT]

unread,
Jan 16, 2003, 7:57:25 AM1/16/03
to
Use the FileInfo.MoveTo() method.

--

Mark Bower
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.


"BIG555" <sricha...@hotmail.com> wrote in message
news:u#E2hWyuCHA.2592@TK2MSFTNGP10...

BIG555

unread,
Jan 16, 2003, 10:14:24 AM1/16/03
to
Thank you...This worked

"BIG555" <sricha...@hotmail.com> wrote in message
news:u#E2hWyuCHA.2592@TK2MSFTNGP10...

0 new messages