Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
test = System.IO.Directory.GetFiles("C:\\test1");
foreach(string t in test)
{
System.IO.File.Copy(t, "f:\\test2\\" + System.IO.Path.GetFileName(t) );
//TextBox required for the following line to work
//Shows each file in the directory
//textBox1.AppendText(t + (char) 13 + (char) 10);
}
string[] test;
private void CopyAllFiles(string strSourcedirectory, string strDestinationDirectory, bool bCheckSubdir)
{
//Debugging Statement - Allows you to see which variables are passed in
//to the subroutine
//MessageBox.Show("Input Vars: " + strSourcedirectory + ", " + strDestinationDirectory + ", " + bCheckSubdir);
string foldername, newDestDir;
//If the destination directory doesn't exist, then create it
if(System.IO.Directory.Exists(strDestinationDirectory) == false)
{
System.IO.Directory.CreateDirectory(strDestinationDirectory);
//textBox1.AppendText("New Directory1: " + strDestinationDirectory + (char) 13 + (char) 10);
}
if(bCheckSubdir)
{
//local variable
string[] ListOfSubdirectories= System.IO.Directory.GetDirectories(strSourcedirectory);
foreach(string dir in ListOfSubdirectories)
{
//the folder name of the subdirectory
foldername = dir.Substring(strSourcedirectory.Length+1, dir.Length-strSourcedirectory.Length-1);
//The new destination directory
newDestDir = strDestinationDirectory + "\\" + foldername;
//If the destination directory doesn't exist, then create it
if(System.IO.Directory.Exists(newDestDir) == false)
{
System.IO.Directory.CreateDirectory(newDestDir);
//textBox1.AppendText("New Directory2: " + newDestDir + (char) 13 + (char) 10);
}
CopyAllFiles(dir, newDestDir, bCheckSubdir);
}
}
//Get the list of files in the current directory
string [] ListOfFiles = System.IO.Directory.GetFiles(strSourcedirectory);
foreach(string fil in ListOfFiles)
{
//This is where you would add your file condition code
//e.g. Copy the file only if the two file's time and date
// are different
System.IO.File.Copy(fil, strDestinationDirectory + "\\" + System.IO.Path.GetFileName(fil) );
//textBox1.AppendText("File Copy: (" + fil + ", " + strDestinationDirectory + "\\" + System.IO.Path.GetFileName(fil) + ")" + (char) 13 + (char) 10);
}
}
CopyAllFiles("c:\\sourceDir", "c:\\destDir", true);