private bool CopyFolderContents(string SourcePath, string DestinationPath)
{
SourcePath = SourcePath.EndsWith(@"\") ? SourcePath : SourcePath + @"\";
DestinationPath = DestinationPath.EndsWith(@"\") ? DestinationPath : DestinationPath + @"\";
try
{
if (Directory.Exists(SourcePath))
{
if (Directory.Exists(DestinationPath) == false)
{
Directory.CreateDirectory(DestinationPath);
}
foreach (string files in Directory.GetFiles(SourcePath))
{
FileInfo fileInfo = new FileInfo(files);
fileInfo.CopyTo(string.Format(@"{0}\{1}", DestinationPath, fileInfo.Name), true);
}
foreach (string drs in Directory.GetDirectories(SourcePath))
{
DirectoryInfo directoryInfo = new DirectoryInfo(drs);
if (CopyFolderContents(drs, DestinationPath + directoryInfo.Name) == false)
{
return false;
}
}
}
return true;
}
catch (Exception ex)
{
return false;
}
}
Software developer by profession, working for a service and product based organisation in India.
Career graph:
Software Programmer since 2002.
Web Developer in ASP.NET since 2004.
Interests:
I love reading the blogs and articles of technology experts. I love codeproject and stackoverflow .
I love to share knowledge and help the programmers. I appreciate if some body corrects my code or my concepts which helps me learn.