本文整理汇总了C#中GLib.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# GLib.Delete方法的具体用法?C# GLib.Delete怎么用?C# GLib.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLib
的用法示例。
在下文中一共展示了GLib.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
private void Delete(string directory, GLib.IFile dir, bool recursive)
{
if (!dir.Exists) {
return;
}
if (dir.QueryFileType (FileQueryInfoFlags.NofollowSymlinks, null) != FileType.Directory) {
return;
}
// If native, use the System.IO recursive delete
if (dir.IsNative && !DisableNativeOptimizations) {
System.IO.Directory.Delete (directory, recursive);
return;
}
if (recursive) {
foreach (string child in GetFiles (dir, false)) {
FileFactory.NewForUri (child).Delete ();
}
foreach (string child in GetDirectories (dir, false)) {
Delete (child, GetDir (child, true), true);
}
}
dir.Delete ();
}
示例2: DeleteEmptyDirectory
private void DeleteEmptyDirectory(GLib.File directory)
{
// if the directory we're dealing with is not in the
// F-Spot photos directory, don't delete anything,
// even if it is empty
string photo_uri = SafeUri.UriToFilename (Global.PhotoUri.ToString ());
bool path_matched = directory.Path.IndexOf (photo_uri) > -1;
if (directory.Path.Equals (photo_uri) || !path_matched)
return;
if (DirectoryIsEmpty (directory)) {
try {
Log.DebugFormat ("Removing empty directory: {0}", directory.Path);
directory.Delete ();
} catch (GLib.GException e) {
// silently log the exception, but don't re-throw it
// as to not annoy the user
Log.Exception (e);
}
// check to see if the parent is empty
DeleteEmptyDirectory (directory.Parent);
}
}
示例3: Delete
private void Delete (string directory, GLib.File dir, bool recursive)
{
if (!dir.Exists) {
Console.WriteLine ("{0} doesn't exist", directory);
return;
}
if ((dir.QueryFileType (FileQueryInfoFlags.None, null) & FileType.Directory) == 0) {
Console.WriteLine ("{0} isn't directory", directory);
return;
}
// If native, use the System.IO recursive delete
if (dir.IsNative && !DisableNativeOptimizations) {
System.IO.Directory.Delete (directory, recursive);
return;
}
if (recursive) {
foreach (string child in GetFiles (dir, false)) {
FileFactory.NewForUri (child).Delete ();
}
foreach (string child in GetDirectories (dir, false)) {
Delete (child, GetDir (child, true), true);
}
}
dir.Delete ();
}