이 SO post의 기능을 사용하여 폴더 내용을 다른 폴더에 복사하지만 하위 폴더와 해당 내용을 복사하지는 않습니다.하위 폴더가 복사되지 않았습니다
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
// If the source directory does not exist, throw an exception.
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
// If the destination directory does not exist, create it.
if (!Directory.Exists(destDirName))
{
Debug.Log("Directory created.." + destDirName);
Directory.CreateDirectory(destDirName);
}
// Get the file contents of the directory to copy.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
// Create the path to the new copy of the file.
string temppath = Path.Combine(destDirName, file.Name);
// Copy the file.
file.CopyTo(temppath, false);
}
// If copySubDirs is true, copy the subdirectories.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
// Create the subdirectory.
string temppath = Path.Combine(destDirName, subdir.Name);
// Copy the subdirectories.
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
이라고하는 방법입니다
string destingationPath = startupFolder + @"\NetworkingDemoPlayerWithNetworkAwareShooting1_Data";
DirectoryCopy("NetworkingDemoPlayerWithNetworkAwareShooting1_Data", destingationPath, true);
가능한 복제의에 공간이 충분하지 의미 [C#에서 디렉터리의 전체 내용을 복사하는 가장 좋은 방법은] (http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c - 샤프) – BartoszKP
당신의 코드 worke 나를 위해 완벽하게 잘 ... 그것은 모든 디렉토리와 하위 디렉토리를 복사했습니다. 한 번 호출 방법의 경로를 확인해 주시겠습니까? – A3006
복사를 방해하는이 예외가있는 것 같음 IOException : Win32 IO가 112를 반환했습니다. –