Renaming a file

  • Thread starter Thread starter Richard L Rosenheim
  • Start date Start date
R

Richard L Rosenheim

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
 
Richard,

I've always done it like that, which is pretty straightforward. However, if
anyone knows a better/different way...
 
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
 
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
 
Nishith Pathak said:
There is Rename function available in Microsoft.VisualBasic namespace and is
only available to VB.Net and not to other language like C#.

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.
 
Yes -
Afraid so. You have to move the file for renaming. I have also
faced same prob.

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
replace certain words in my E-Mail address.
 
Back
Top