I get this error when I attempt to open a Visio document and save it as a pdf:
protected void ViewVisio(string url)
{
string pdfFile = Server.MapPath("/Files/test.pdf");
Microsoft.Office.Interop.Visio.Application visApp =
new Microsoft.Office.Interop.Visio.Application();
Microsoft.Office.Interop.Visio.Document visDoc =
visApp.Documents.Open(url.ToString()); // error occurs here
visDoc.ExportAsFixedFormat(
Microsoft.Office.Interop.Visio.VisFixedFormatTypes.visFixedFormatPDF,
pdfFile,
Microsoft.Office.Interop.Visio.VisDocExIntent.visDocExIntentScreen,
Microsoft.Office.Interop.Visio.VisPrintOutRange.visPrintAll, 1, -1,
false, true, true, true, false, System.Reflection.Missing.Value);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.TransmitFile(pdfFile);
Response.Flush();
Response.End();
}
This is the error I'm getting:
System.Runtime.InteropServices.COMException: There is a file sharing conflict. The file cannot be accessed as requested.
Stack trace:
Stack Trace:
[COMException (0x86db097e):
There is a file sharing conflict. The file cannot be accessed as requested.]
Microsoft.Office.Interop.Visio.DocumentsClass.Open(String FileName) +0
...
Anyone know what this issue is? I can't find any details on it.
It simply means that another application has your file open and therefore has a lock on it. Do you have the document open in Visio when you are running your program?
You can verify which process has a hold on the file by running the SysInternals Handle tool for file ownership: http://technet.microsoft.com/en-us/sysinternals/bb896655