TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Arun Kumar Radhakrishnan
NA
20
19.7k
How to copy a file from one folder to another in C#?
Aug 25 2014 12:38 AM
Hai guys, Hope you are all doing fine. Now I am working in file uploading process. process of uploading the file from the system is working good but my problem is I want to move the uploaded file from that folder to another folder I tried few samples but all the samples are creating a same error "
Could not find a part of the path 'D:\CMS\app\views\UploadDocumets\geography_ssc_capsule_7.pdf'.
" the code that I use is given below, please help me to solve this problem friends.
string fileName = Filenames;
(name of the file that I uploaded)
string sourcePath = @"D:\CMS\app\views\UploadDocumets";
string targetPath = @"D:\Projects\aanthony_23Mar2013\UpLoadDocuments";
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
System.IO.File.Copy(sourceFile, destFile, true);
if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach (string s in files)
{
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}
else
{
}
Thank you very much
Reply
Answers (
1
)
creating Sequecnce siagram from c# source automatically
How to call stored procedure in to light switch solution?