Visual Studio 2008 の拡張機能を使用して、インターフェイスの解析後にさまざまなメッセージを含むプロジェクト フォルダーを作成するアドインを作成しようとしています。ただし、フォルダーの作成/追加の段階で問題があります。使ってみました
ProjectItem folder =
item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty);
(アイテムは、同じ名前で「メッセージ」が追加されたフォルダーを作成している隣のターゲットファイルです)が、フォルダーが既に存在する場合はチョークします(大きな驚きはありません)。
次のように、既に存在する場合は削除してみました。
DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent +
newDirectoryName);
if (dirInfo.Exists)
{
dirInfo.Delete(true);
}
ProjectItem folder =
item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty);
デバッグ中にフォルダーが削除されることがわかりますが、それでもフォルダーがまだそこにあり、フォルダーが既に存在するという例外で死ぬと考えているようです。
何か案は???
ありがとう。
AK
....おそらく答えは、削除後にプロジェクトをプログラムで更新することにあるでしょうか? これはどのように行うことができますか?