Hello,
I am using Team foundation system and I have requirement in which I want to copy all the checkout files to a local folder along with the same folder structure using C#. How can I do that?
Huzaifa
Hello,
I am using Team foundation system and I have requirement in which I want to copy all the checkout files to a local folder along with the same folder structure using C#. How can I do that?
Huzaifa
I don't know what you mean by the "checkout files", but if you want to copy a directory you have to:
The following will enumerate all of the files and folders in a directory:
static void FullDirList(DirectoryInfo dir, string searchPattern)
{
Console.WriteLine("Directory {0}", dir.FullName);
// list the files
foreach (FileInfo f in dir.GetFiles(searchPattern))
{
Console.WriteLine("File {0}", f.FullName);
}
// process each directory
foreach (DirectoryInfo d in dir.GetDirectories())
{
FullDirList(d, searchPattern);
}
}
If you call that with FullDirList("C:\MyProject\", *.*)
, it will enumerate all of the files.
To create destination folders or copy files, change the calls to Console.WriteLine
so that they do the appropriate thing. All you should have to change in the destination file or folder names is the root folder name (that is, if you're copying from C:\MyProject\ to C:\MyProjectCopy\, then the destination files are just f.FullName
with the C:\MyProject\ replaced by C:\MyProjectCopy).