Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
System.IO.Path.Combine to merge File Path
WhatsApp
Venkatesan Jayakantham
12y
64.7
k
0
1
25
Blog
System.IO.Path.Combine to merget file path in c#
Just come across an interesting method
System.IO.Path.Combine
. Thought of sharing with my blog readers. This method is used to merge the path of the file with another string.
string fileName = "test.txt";
string sourcePath = @"C:\Users\Public\TestFolder";
string targetPath = @"C:\Users\Public\TestFolder\SubDir";
// Use Path class to manipulate file and directory paths.
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
// To copy a folder's contents to a new location:
// Create a new target folder, if necessary.
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
// To copy a file to another location and
// overwrite the destination file if it already exists.
System.IO.File.Copy(sourceFile, destFile, true);
Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
http://www.kaashivinfotech.com/
System.IO.Path.Combine to merge File Path
Up Next
Retrieving all the available Fonts from the Windows font folder using System.IO C#
Ebook Download
View all
Diving Into Microsoft .NET Entity Framework
Read by 13.3k people
Download Now!
Learn
View all
Membership not found