473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Renaming a file

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
Nov 22 '05 #1
5 3587
CT
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
"Richard L Rosenheim" <ri*****@rlr.co m> wrote in message
news:Ov******** ********@TK2MSF TNGP12.phx.gbl. ..
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

Nov 22 '05 #2
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
Richard L Rosenheim <ri*****@rlr.co m> wrote in message
<Ov************ **@TK2MSFTNGP12 .phx.gbl>
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

Nov 22 '05 #3
Dear all,

There is Rename function available in Microsoft.Visua lBasic 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

"Shankara Narayanan" wrote:
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
Richard L Rosenheim <ri*****@rlr.co m> wrote in message
<Ov************ **@TK2MSFTNGP12 .phx.gbl>
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

Nov 22 '05 #4
Nishith Pathak <Ni***********@ discussions.mic rosoft.com> wrote:
There is Rename function available in Microsoft.Visua lBasic namespace and is
only available to VB.Net and not to other language like C#.


No, you can use the Microsoft.Visua lBasic 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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #5
On Wed, 27 Oct 2004 12:24:10 +0530, Shankara Narayanan wrote:
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_lunch meat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2061
by: peter | last post by:
Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves renaming functions etc... I came across some recursive problems. (a basic construct can be found under the section BASIC CODE) These problems do not...
5
439
by: Richard L Rosenheim | last post by:
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
0
1957
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the new name gets displayed through refreshing of my loop and display function. The problem is that when, if I rename the last file entry, everything...
0
1343
by: Andy | last post by:
Hello: I am using System.Web.Mail.MailMessage. Currently: when I am attaching a file to the object, I am renaming the file using the FileInfo.Copy method and attaching the new file to the email: sNewFileName = fPath + "Front" + fInfo.Extension; fInfo.CopyTo(sNewFileName, true); fInfo.Delete(); oMail.Attachments.Add(new...
2
6398
by: cloudx | last post by:
Hi there, it is driving me crazy. Aftering renaming app.config the following code I always get null on myApp. It works if I keep the name app.config. Why? string myApp = ConfigurationSettings.AppSettings; Thanks!
1
3789
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the new name gets displayed through refreshing of my loop and display function. The problem is that when, if I rename the last file entry, everything...
1
2740
by: Jason B | last post by:
Hello, I have been trying to figure out how to rename my IIS directories and still have the project be able to run through VS. I have renamed the directories listed in the csproj.webinfo file and this allowed me to at least load the project into Visual Studio. However, if I try to run the asp.net project through VS I get a lenghty error to the...
5
4704
by: bulldog8 | last post by:
I've read numerous posts and have tried multiple approaches that I found, but just cannot get a file renamed. I am using VB.Net 2002 ... Here is what I have tried: 1) Code common to all attempts: OldName = "c:\albums\061203\email\DSC07272.JPG" NewName = "c:\albums\061203\email\Lalala.JPG"
1
3007
by: rush81 | last post by:
i'm trying to create an ssis package for renaming and moving the file. It gives error at the file system task: Error: An error occurred with the following error message: "Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\abc123.xlsabc.xls'.". the file is abc123.xls. Now why is it pointing to the C drive? I have...
3
1857
by: NIKHILUNNIKRISHNAN | last post by:
Experts, I am getting file not found error while enabling the Renaming option of dotfuscator 4.4 Professional. Can any who has experience in this field help me out ? with advance thanks, Nikhil Unnikrishnan.
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.