Groups | Blog | Home
all groups > dotnet general > october 2004 >

dotnet general : Renaming a file


Richard L Rosenheim
10/26/2004 11:06:18 PM
Correct me if I'm wrong...

It appears that out of the 1800+ classes in the .Net framework, there isn't
a file rename method (discounting the rename function in the vb namespace).
And that the solution is to move the file to the same directory with a
different destination name.

Does that correctly summarize it?

Richard

Nishith Pathak
10/27/2004 2:35:08 AM
Dear all,

There is Rename function available in Microsoft.VisualBasic namespace and is
only available to VB.Net and not to other language like C#. seems strange
when i do it. But the best universal and standard solution to rename the file
is to use the File.Move method but in case if you r working on VB.NET, you
got the rename function to rename your files.

Nishith



[quoted text, click to view]
CT
10/27/2004 8:44:17 AM
Richard,

I've always done it like that, which is pretty straightforward. However, if
anyone knows a better/different way...

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
[quoted text, click to view]

Chris Dunaway
10/27/2004 9:13:25 AM
[quoted text, click to view]

Why is that a problem? It works as intended. When calling the Move method
to the same folder, I believe it just changes the name and does not
actually "move" anything.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
Jon Skeet [C# MVP]
10/27/2004 11:24:34 AM
[quoted text, click to view]

No, you can use the Microsoft.VisualBasic namespace from C#. The Rename
method is a static one in the FileSystem class.

I can't see that it's likely to have a significantly different effect
to using File.Move though.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Shankara Narayanan
10/27/2004 12:24:10 PM
Yes -
Afraid so. You have to move the file for renaming. I have also
faced same prob.
Shankar
10/27/2004 11:36:18 AM
[quoted text, click to view]
AddThis Social Bookmark Button