2017-03-15 3 views
0

솔루션 폴더 안에 Debug에 폴더가 저장되어 있지만이 폴더를 다른 폴더에 복사하려고하면 "Access to the directory is denied"예외가 발생합니다.디렉터리 경로에 대한 액세스가 거부되었습니다.

if (!System.IO.Directory.Exists(@"Exported Files")) 
{ 
    var di = new DirectoryInfo(@"SBooks"); 
    di.Attributes &= ~FileAttributes.Directory; 
    System.IO.File.Copy(@"SBooks", @"Exported Files\\"); 
} 
+0

어떤 기술을 사용하고 있습니까? webform? mvc? wpf? winform? – Valkyrie

+2

[파일을 복사 할 수 없으며 경로에 대한 액세스가 거부되었습니다] 가능한 복제본 (http://stackoverflow.com/questions/7130136/unable-to-copy-file-access-to-the-path-is-denied)) – jjj

+0

창 양식 응용 프로그램, 파일에 중복이 없습니다. – Hesham

답변

0

사용 하나 백 슬래시는 @를 사용하는 경우 (this 참조).

File.Copy(@"SBooks", @"Exported Files\") 
관련 문제