2013-05-09 2 views
0

동일한 네트워크의 먼 디렉토리에서 파일을 복사해야합니다. 나는이 디렉토리에 액세스 할 수가 성공 :네트워크의 디렉토리 공유 C#

public void CopyDir(string sourceDir, string destDir) 
     { 
      DirectoryInfo dir = new DirectoryInfo(sourceDir); 
      if (dir.Exists) 
      { 
       string realDestDir; 
       if (dir.Root.Name != dir.Name) 
       { 
        realDestDir = System.IO.Path.Combine(destDir, dir.Name); 
        if (!Directory.Exists(realDestDir)) 
         Directory.CreateDirectory(realDestDir); 
       } 
       else realDestDir = destDir; 
       foreach (string d in Directory.GetDirectories(sourceDir)) 
        CopyDir(d, realDestDir); 
       foreach (string file in Directory.GetFiles(sourceDir)) 
       { 

        string fileNameDest = System.IO.Path.Combine(realDestDir, System.IO.Path.GetFileName(file)); 
        if (!File.Exists(fileNameDest)) 

        File.Copy(file, fileNameDest, true); 
       } 
      } 
     } 

그러나 오류가 Could not find a part of the path 'StlDirectory \ BM529234-CRL39-LF.stl' 나타납니다 :

string[] parts = Regex.Split(@directory_path, @"\\"); 
       // l'emplacement de repertoire \\nom de la machine\nomde repertoire 
      string distant_directory = @"\\"+Environment.MachineName+ @"\" + parts[parts.Length - 2]; 
      string local_directory = @"StlDirectory"; 
      CopyDir(distant_directory, local_directory); 

복사본의 기능은 다음과 같다.

  1. 왜이 오류가 표시됩니까?
  2. 어떻게 해결할 수 있습니까?
+0

없는 존재하지 않는 생각? – KF2

+0

무엇의 주소? –

+1

귀하의 주소를 분할하는 동안 문제가 있다고 생각합니다.이 오류는 '경로의 일부를 찾을 수 없습니다'StlDirectory \ BM529234-CRL39-LF.stl'' 디렉토리 dosent가 있기 때문에 – KF2

답변

0

응용 프로그램 IIS 응용 프로그램 풀 등이이 디렉터리에 액세스 할 수있는 보안 권한을 가지고 있는지 확인 했습니까?

0

나는 심지어 목적지 레퍼토리는 복사의 기능 (레퍼토리 + 사본의 생성을) 작동하지만 당신이 당신의 주소를 추가 할 수 있습니다 경우

관련 문제