Tag not monitored by Microsoft.
Hi @Emi Zhang-MSFT ,
thanks for your information.
I posted my question in General Office Development forum.
Regards,
Giulio
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everyone,
I have a problem using Presentation.Slides.InsertFromFile method because after this istruction my file can not be deleted.
The system returns the error "The process cannot access the file 'C:\temp\pptFiles\internal\Copy_InternalFileName.pptx' because it is being used by another process.".
I do not know why the method InsertFromFile lock my file.
Could you have any idea how can I unlock and delete the file?
Thanks,
Giulio
This is my code:
public void UpdateDocument(DocumentWrapper wrapper)
{
string internalFileName = @"C:\temp\pptFiles\internal\InternalFileName.pptx";
string internalCopyFileName = internalFileName.Replace("Internal", "Copy_Internal");
FileInfo fileInfo = new FileInfo(internalCopyFileName);
if (fileInfo.Exists)
{
fileInfo.Delete();
}
File.Copy(internalFileName, internalCopyFileName);
Globals.ThisAddIn.Application.Presentations.Open(internalCopyFileName,
MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
globalPresentation = (Presentation) wrapper.presentation;
globalPresentation.Slides.InsertFromFile(internalCopyFileName, 0, 1, 1);
globalPresentation.Save();
try
{
System.IO.File.Delete(internalCopyFileName);
}
catch (Exception exception)
{
Console.WriteLine(exception);
throw;
}
}
Tag not monitored by Microsoft.
Hi @Emi Zhang-MSFT ,
thanks for your information.
I posted my question in General Office Development forum.
Regards,
Giulio
Hi,
Based on your description, I suggest you post this issue to General Office Development forum:
https://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.