Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Charlie on May 04, 2007, 03:06:04 am
-
Hi,
I'm trying to add a file to an element. However, using the code example below, the file is not saving.
private void AddFileToPackage(EA.Package package, string urlAddress)
{
....if (package != null)
....{
........if (package.Element != null)
........{
............package.Element.Files.AddNew(urlAddress, "Web Address");
............package.Element.Update();
............package.Update();
........}
....}
}
Anyone got any ideas what I'm doing wrong?
-
You appear to be saving the element and package with .Update(), but not the file.
Try capturing the file to a variable, and then calling update on the variable. Something along the lines of:
(EA.File) foo = package.Element.Files.AddNew(urlAddress, "Web Address");
foo.Update();
David
-
Great thanks...all working now. C# code below:
EA.File file = package.Element.Files.AddNew(urlAddress, "Web Address") as EA.File;
file.Update();