두 개의 PDF 파일을 병합해야합니다. 그러나 때로는 파일이 코드를 작성 파일을 복사하는 가장 안전한 방법
을 고정 할 수 있지만,이 똑똑한 솔루션이 아니라면 궁금하네요 : 당신이 잠을 수 있도록 당신은 몇 번의 클릭에 대한 타이머를 추가해야 private static int FILE_LOCKED_WAIT_PERIOD = 1000;
while (true)
{
// If the file is in use, IOException will be thrown.
// If file is not permitted to be opened because of Permission
// Restrictions, UnauthorizedAccessException will be thrown.
// For all other, Use normal Exception.
try
{
inputDocument1 = PdfReader.Open(fileToMerge, PdfDocumentOpenMode.Import);
break;
}
catch (IOException)
{
Thread.Sleep(FILE_LOCKED_WAIT_PERIOD);
}
catch (UnauthorizedAccessException)
{
Thread.Sleep(FILE_LOCKED_WAIT_PERIOD);
}
catch (Exception)
{
Thread.Sleep(FILE_LOCKED_WAIT_PERIOD);
}
}
가능한 복제본 : http://stackoverflow.com/questions/1563191/c-cleanest-way- 쓰기 재시도 - 논리 –
@aron : 위 링크에서 질문에 대한 대답을 알려주십시오. 질문의 정확한 복제물처럼 보이지 않지만 내용이 여전히 도움이 될 수 있습니다. –