Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Move a directory in C#
WhatsApp
Mahesh Chand
6y
105.1k
0
3
100
Article
The System.IO.Directory class in the .NET Framework class library provides static methods for creating, copying, moving, and deleting directories and subdirectories. Before you can use the Directory class, you must import the System.IO namespace.
using
System.IO;
Move a directory in C#
The Directory.Move method moves an existing directory to a new specified directory with full path. The Move method takes two parameters. The Move method deletes the original directory.
The following code snippet moves the source directory to the destination directory.
string
sourceDirName = @
"C:\Temp"
;
string
destDirName = @
"C:\NewTemp"
;
try
{
Directory.Move(sourceDirName, destDirName);
}
catch
(IOException exp)
{
Console.WriteLine(exp.Message);
}
Next>>
Directories in C#
.NET move directory
Directory.Move
move folder using C#
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.4k people
Download Now!
Learn
View all
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.
Membership not found