本文整理汇总了C#中SPSite.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# SPSite.Delete方法的具体用法?C# SPSite.Delete怎么用?C# SPSite.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPSite
的用法示例。
在下文中一共展示了SPSite.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteTask
/// <summary>
/// Task for deleting a SPSite.
/// </summary>
protected override void ExecuteTask() {
try {
SPSite site = new SPSite(Url);
site.Delete();
Log(Level.Info, LogPrefix + "Deleting site {0}.", Url);
} catch (FileNotFoundException ex) {
// The SPS API will throw an exception when you try and create an
// instance of SPSite for a URL that doesn't exist.
throw new BuildException(
string.Format("Cannot delete site {0}. The site does not exist.",
Url), Location, ex);
}
}
示例2: TearDown
protected override void TearDown() {
DirectoryEntry root = new DirectoryEntry(_rootDirectory);
DirectoryEntry newUserEntry = root.Children.Find(_newUserName);
root.Children.Remove(newUserEntry);
DirectoryEntry userEntry = root.Children.Find(_userName);
root.Children.Remove(userEntry);
try {
SPSite site = new SPSite(_newSPSiteUrl);
site.Delete();
} catch (FileNotFoundException) {
// If a FileNotFoundException was raised it was because the site was
// correctly deleted by the test.
}
}
示例3: TearDown
protected override void TearDown() {
try
{
DirectoryEntry root = new DirectoryEntry(_rootDirectory);
DirectoryEntry userEntry = root.Children.Find(_userName);
root.Children.Remove(userEntry);
root.CommitChanges();
SPSite site = new SPSite(_newSPSiteUrl);
site.Delete();
} catch {
}
}
示例4: btnMove_Click
protected void btnMove_Click(object sender, EventArgs e)
{
if (ThisWebPart.DestionationSiteCollectionUrl != null)
{
oSite = new SPSite(ThisWebPart.DestionationSiteCollectionUrl + "/jobs/" + DateTime.Now.Year);
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPWeb sourceWeb = new SPSite(SPContext.Current.Web.Url).OpenWeb())
{
SPExportSettings settings = new SPExportSettings();
settings.SiteUrl = sourceWeb.Site.Url;
settings.ExportMethod = SPExportMethodType.ExportAll;
settings.FileLocation = ThisWebPart.ExportLocation;
settings.FileCompression = false;
settings.CommandLineVerbose = true;
settings.OverwriteExistingDataFile = true;
foreach (SPList item in sourceWeb.Lists)
{
SPExportObject exportObject = new SPExportObject();
exportObject.Id = item.ID;
exportObject.Type = SPDeploymentObjectType.List;
settings.ExportObjects.Add(exportObject);
}
SPExport export = new SPExport(settings);
export.Run();
}
});
SPWeb destinationWeb = new SPSite(lstJobs.SelectedItem.Value).OpenWeb();
SPSecurity.RunWithElevatedPrivileges(delegate
{
HttpContext.Current.Items["FormDigestValidated"] = "false";
destinationWeb.AllowUnsafeUpdates = true;
SPImportSettings settings = new SPImportSettings();
settings.SiteUrl = destinationWeb.Site.Url;
settings.WebUrl = lstJobs.SelectedItem.Value;
settings.FileLocation = ThisWebPart.ExportLocation;
settings.FileCompression = false;
settings.RetainObjectIdentity = false;
settings.LogFilePath = ThisWebPart.ExportLocation + @"\export_log.txt";
settings.IgnoreWebParts = true;
SPImport import = new SPImport(settings);
import.Run();
HttpContext.Current.Items["FormDigestValidated"] = "false";
destinationWeb.AllowUnsafeUpdates = false;
});
var currentUser = Request.LogonUserIdentity.ToString();
SPSecurity.RunWithElevatedPrivileges(delegate
{
SPWeb sourceWeb = new SPSite(SPContext.Current.Web.Url).OpenWeb();
SPWeb blueberryWeb = sourceWeb.Site.AllWebs["Blueberry"];
SPList proposalList = blueberryWeb.Lists["Proposals"];
var proposalRecordID = int.Parse(sourceWeb.Properties["ProposalRecordID"].ToString());
SPListItem proposalRecord = proposalList.GetItemById(proposalRecordID);
proposalRecord["JobNumber"] = lstJobs.SelectedItem.Text;
proposalRecord["BecameJobOn"] = DateTime.Now;
proposalRecord.Update();
sourceWeb.AllowUnsafeUpdates = true;
sourceWeb.Delete();
});
Response.Redirect(destinationWeb.Url);
}
}