none
C# - How to perform XCopy file operation in .NET 3.5 RRS feed

  • Question

  • Dear All,

      In .NET 3.5 C#, how to perform XCopy function?

      Any library to use? Can it use VB.NET library?

    Monday, February 18, 2013 8:46 AM

Answers

  • A .NET folder to folder copy method is

    Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory()

    • Marked as answer by Geossl Tuesday, February 19, 2013 1:52 AM
    • Unmarked as answer by Geossl Tuesday, February 19, 2013 1:52 AM
    • Marked as answer by Geossl Tuesday, February 19, 2013 1:53 AM
    Monday, February 18, 2013 4:48 PM

All replies

  • What exactly does you want to do?

    If you just need simple file copy, FileInfo.CopyTo() will do.

    If you need to set or clear Archive bit, use FileInfo.Attributes.

    Use DirectoryInfo.GetDirectories() and DirectoryInfo.GetFiles() to iterrate against folders.

    Monday, February 18, 2013 9:48 AM
    Answerer
  • Use the System.Diagnostics.Process class to shell cmd.exe with the parameters you want.

    The VBConsole program on my SkyDrive has the details.

    • Proposed as answer by Cor Ligthert Monday, February 18, 2013 11:23 AM
    • Edited by JohnWein Monday, February 18, 2013 4:16 PM
    Monday, February 18, 2013 10:33 AM
  • No there is no Folder to Folder copy (XCopy) available as .Net method.

    So you can do it file by file or using the XCopy Shell function like John wrote.


    Success
    Cor

    Monday, February 18, 2013 11:24 AM
  • A .NET folder to folder copy method is

    Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory()

    • Marked as answer by Geossl Tuesday, February 19, 2013 1:52 AM
    • Unmarked as answer by Geossl Tuesday, February 19, 2013 1:52 AM
    • Marked as answer by Geossl Tuesday, February 19, 2013 1:53 AM
    Monday, February 18, 2013 4:48 PM
  • A .NET folder to folder copy method is

    Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory()

    Good one John, 

    100 points for you, 

    (One of the things I try to avoid is the My Class from VB from which this is a part).

    Probably is it simply an implementation of the by me proposed answer from you.

    :-)

    But you are right, it is a true Net method in all full versions since framework2.0

    :-)


    Success
    Cor

    Monday, February 18, 2013 7:02 PM
  • Yup. This is valid choice if "suspend/resume copy" feature offer by xcopy isn't important.
    Tuesday, February 19, 2013 2:22 AM
    Answerer