이 단어를 pdf 파일로 변환하려고합니다. 그러나 오류가 발생했습니다. "다른 프로세스에서이 프로세스를 사용하고 있기 때문에 프로세스가 파일에 액세스 할 수 없습니다."오류 다른 프로세스에서 사용 중이기 때문에 프로세스가 파일에 액세스 할 수 없습니다.
public Microsoft.Office.Interop.Word.Document wordDocuments { get; set; }
Microsoft.Office.Interop.Word.Application apword = new Microsoft.Office.Interop.Word.Application();
try
{
if (uploadFInput.HasFile)
{
targetPathip = Server.MapPath(Path.GetFileName(uploadFInput.PostedFile.FileName));
if (File.Exists(targetPathip))
{
File.Delete(targetPathip);
}
string Extentsion_path = Path.GetExtension(targetPathip);
string Filename_path = Path.GetFileName(targetPathip);
if (Extentsion_path == ".doc" || Extentsion_path == ".docx")
{
uploadFInput.SaveAs(targetPathip);
LblFleip.Text = targetPathip;
//wordDocuments = apword.Documents.Open(Filename_path);
wordDocuments = apword.Documents.Open(Filename_path);
// wordDocuments = apword.Documents.Open(targetPathip);
wordDocuments.ExportAsFixedFormat(Filename_path, WdExportFormat.wdExportFormatPDF);
apword.Documents.Close(Filename_path);
}
string filename = Path.GetFileName(targetPathip);
uploadFInput.SaveAs(targetPathip);
LblFleip.Text = targetPathip;
}
}
catch (Exception ex)
{
apword = null;
return;
}
변환하는 동안 내 코드에 누락 된 부분이 있습니까? 누구든지 pdf로 낱말을 개조하는 방법 저에게 말할 수있다.
'wordDocuments = apword.Documents.Open (Filename_path) .. wordDocuments.ExportAsFixedFormat (Filename_path, X)'- 동일한 파일명이 * 매우 * 의심 스럽습니다. – user2246674
@ user2246674 Windows에서 동일한 코드가 작동했습니다. – pdp
이 코드를 실행하면 실제 단어 문서가 바탕 화면에 열리지 않습니까? –