Last active
December 21, 2018 14:37
-
-
Save AnshulKuthiala/f49e7d9c545f2668637426551d2c232e to your computer and use it in GitHub Desktop.
[Remove Customization] #ExcelHelper Remove document customization from document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add reference to using Microsoft.VisualStudio.Tools.Applications.ServerDocument | |
using Microsoft.VisualStudio.Tools.Applications; | |
private static void RemoveCustomiation(string filePath, int attempt) | |
{ | |
int maxAttempt = 10; | |
try | |
{ | |
ServerDocument.RemoveCustomization(filePath); | |
} | |
catch (IOException) | |
{ | |
if (attempt <= maxAttempt) | |
{ | |
attempt++; | |
Thread.Sleep(1000); | |
RemoveCustomiation(filePath, attempt); | |
} | |
else | |
{ | |
throw new Exception("Unable to remove customization."); | |
} | |
} | |
catch (Exception) | |
{ | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment