本文整理汇总了C#中System.IO.DirectoryInfo.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.Remove方法的具体用法?C# DirectoryInfo.Remove怎么用?C# DirectoryInfo.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFolder
/// <summary>
/// Adds a folder to the zip file
/// </summary>
/// <param name="Folder">Folder to add</param>
public virtual void AddFolder(string Folder)
{
Folder.ThrowIfNullOrEmpty("Folder");
Folder = new DirectoryInfo(Folder).FullName;
if (Folder.EndsWith(@"\"))
Folder = Folder.Remove(Folder.Length - 1);
using (Package Package = ZipPackage.Open(ZipFileStream, FileMode.OpenOrCreate))
{
new DirectoryInfo(Folder)
.GetFiles()
.ForEach(x => AddFile(x.FullName.Replace(Folder, ""), x, Package));
}
}
示例2: InitLogger
public static void InitLogger()
{
if (!Directory.Exists(LogFolder))
Directory.CreateDirectory(LogFolder);
var logs = new DirectoryInfo(LogFolder).GetFiles().OrderBy(s => s.LastWriteTime).ToList();
while (logs.Count() >= ServerMain.settings.maximumLogs)
{
var first = logs.First();
first.Delete();
logs.Remove(first);
}
}
示例3: AddFolder
public virtual void AddFolder(string Folder)
{
Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(Folder), "Folder");
Folder = new DirectoryInfo(Folder).FullName;
if (Folder.EndsWith(@"\", StringComparison.InvariantCulture))
Folder = Folder.Remove(Folder.Length - 1);
using (Package Package = ZipPackage.Open(ZipFileStream, FileMode.OpenOrCreate))
{
new DirectoryInfo(Folder)
.GetFiles()
.ForEach(x => AddFile(x.FullName.Replace(Folder, ""), x, Package));
}
}
示例4: DeleteGallery
/// <summary>
/// Deletes gallery
/// </summary>
/// <param name="id">Gallery identifier</param>
public static bool DeleteGallery(int id)
{
lock (GetGallerySyncRoot(id))
{
OperationResult<OperationResults, Nullable<bool>> rslt = null;
try
{
rslt = GalleryRepository.DeleteGallery(id);
}
catch (Exception ex)
{
Logger.WriteError(ex);
throw;
}
switch (rslt.Result)
{
case OperationResults.Success:
case OperationResults.NotFound:
{
var dir = new DirectoryInfo(GetGalleryDevPath(id));
if (dir.Exists)
{
try
{
dir.Remove();
}
catch (Exception ex)
{
Logger.WriteError(ex);
}
}
RemoveGallerySyncRoot(id);
return true;
}
case OperationResults.Failure:
return false;
default:
throw new NotImplementedException();
}
}
}