0

I am working on C#.net console application in app i have two folders 1)D:\Working Projects\Alticore\AssetXML\LIS, 2)D:\Working Projects\Alticore\AssetXMLProcessed.

Now i want to copy only sub-folder(i.e LIS) from D:\Working Projects\Alticore\AssetXML\LIS to D:\Working Projects\Alticore\AssetXMLProcessed.

That is xaclty like this "D:\Working Projects\Alticore\AssetXMLProcessed/LIS".

Any solution to this problem I'll be appreciate.

leppie
  • 115,091
  • 17
  • 196
  • 297
Indra
  • 279
  • 2
  • 3
  • 16

3 Answers3

0

Under Windows XP, it would be thus:

move "c:\documents and settings\%USERNAME%\desktop\TZClock" "C:\documents and settings\%USERNAME%\Start Menu\Programs\TZClock"

On Windows 7, it is the following (though I'm not in a position to test this right now):

move "c:\users\%USERNAME%\desktop\TZClock" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\TZClock"

you can execute this process or another thing create new file copy all data.

Pulah Nandha
  • 774
  • 4
  • 23
0

This should do the job

public static void Copy(String srcPath, String destPath)
{
    DirectoryInfo srcDirectory = new DirectoryInfo(srcPath);
    if (!srcDirectory.Exists) return;

    // Creates LIS directory
    destPath = Path.Combine(Path.Combine(destPath, srcDirectory.Name));
    Directory.CreateDirectory(destPath);

    // Creates all sub directories from srcPath to your destPath
    foreach (String dirPath in Directory.GetDirectories(srcPath, "*", SearchOption.AllDirectories))
        Directory.CreateDirectory(dirPath.Replace(srcPath, destPath));

    // Copies all files from all sub directories from srcPath to your destPath
    foreach (String copyPath in Directory.GetFiles(srcPath, "*.*", SearchOption.AllDirectories))
        File.Copy(copyPath, copyPath.Replace(srcPath, destPath), true);
}

Usage:

Copy(@"D:\Working Projects\Alticore\AssetXML\LIS", @"D:\Working Projects\Alticore\AssetXMLProcessed")

If you don't want to copy sub folders or its files remove not needed foreach. By the way it will override copied files.

0

There is one more option what you can do is there is
File.Copy(src, dest) method in the System.IO namespace you can also go with that.