示例#1
0
        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();
        }