943,532 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2879
  • C# RSS
Sep 18th, 2009
0

How to change folder or file name using C# ?

Expand Post »
I'm making a project that gets folder and file names in a specific path and I want to edit the folder or file names? (e.g: folder name is X.Men.DVDrip I want to change it to X Men DVDrip)
I have the path of the folder, but I dont know how to change the file name.

Can anyone help me with this issue ?
(am using VS C# 2008)

Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
BullzEyezz is offline Offline
2 posts
since Sep 2009
Sep 18th, 2009
0

Re: How to change folder or file name using C# ?

File | You may use Move method in System.IO like that
C# Syntax (Toggle Plain Text)
  1. System.IO.File.Move(@"C:\old.txt", @"C:\new.txt"); //it renames the file old to new.txt

Folder | the same
C# Syntax (Toggle Plain Text)
  1. System.IO.Directory.Move(@"C:\oldfolder", @"C:\newfolder");
Last edited by Ramy Mahrous; Sep 18th, 2009 at 8:39 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: How to change folder or file name using C# ?

Thanks a lot Ramy. I'll give it a try
Reputation Points: 10
Solved Threads: 0
Newbie Poster
BullzEyezz is offline Offline
2 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: connection to database
Next Thread in C# Forum Timeline: Calling DestroyEnvironmentBlock on CreateProcessAsUser while it is still running? [C#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC