I have a client that wants to copy an existing webpart from an
existing MOSS 07 page and add that webpart to the "MySite" page.
I know I can use something like this to add a webpart to a page as
long as I have access to the *.webpart or *.dwp file:
public void AddWebPart2()
{
string err = string.Empty;
string chromeType = "Default";
string zoneIndex = "Left";
string Error = string.Empty;
using (SPSite site = new SPSite("http://ford/test"))
{
using (SPWeb web = site.OpenWeb())
{
try
{
SPFile file = web.GetFile("default.aspx");
SPLimitedWebPartManager manager1 =
file.GetLimitedWebPartManager(PersonalizationScope.Shared);
XmlReader reader1 = GetWebPartDef
(@"D:\SampleWebParts\ThisWeekInPictures.dwp");
System.Web.UI.WebControls.WebParts.WebPart
part1 = manager1.ImportWebPart(reader1, out err);
part1.ChromeType = (PartChromeType)Enum.Parse
(typeof(PartChromeType), chromeType);
manager1.AddWebPart(part1, zoneIndex, 1);
}
catch (Exception ex)
{
Error = "AddWebPart2 Error: " + ex.Message;
throw new Exception(Error);
}
} // End of using web
} // End of using site
}
So my question is ... how can I get the *.webpart or *.dwp file from
the webpart gallery? Or do I get it from the webpart gallery? If
not where can I gain access to these/this file from?