当前位置: 首页>>代码示例>>C#>>正文


C# Directory.Delete方法代码示例

本文整理汇总了C#中Directory.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Directory.Delete方法的具体用法?C# Directory.Delete怎么用?C# Directory.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloseFile

        public DokanError CloseFile(string fileName, DokanFileInfo info)
        {
            //Console.WriteLine("CloseFile: {0}", fileName);

            // 可能打开文件时有 deleteOnClose 标记(Windows 8+)
            if (info.Context != null)
            {
                File f = (File)info.Context;
                if (f.flagDeleteOnClose)
                {
                    Directory dir = new Directory(Util.GetPathDirectory(f.path));
                    if (!dir.Exists())
                    {
                        return DokanError.ErrorSuccess;
                    }

                    String name = Util.GetPathFileName(f.path);

                    if (!dir.Contains(name))
                    {
                        return DokanError.ErrorSuccess;
                    }

                    dir.Delete(name);
                }
            }

            return DokanError.ErrorSuccess;
        }
开发者ID:WishSummer,项目名称:FS,代码行数:29,代码来源:FSDrive.cs

示例2: MoveFile

        public DokanError MoveFile(string oldName, string newName, bool replace, DokanFileInfo info)
        {
            //Console.WriteLine("MoveFile: {0} -> {1}, replace = {2}", oldName, newName, replace);

            var dirNameOld = Util.GetPathDirectory(oldName);
            var dirNameNew = Util.GetPathDirectory(newName);
            if (dirNameNew.IndexOf(dirNameOld) > -1 && dirNameNew != dirNameOld)
            {
                return DokanError.ErrorError;
            }

            var dirOld = new Directory(dirNameOld);
            var dirNew = new Directory(dirNameNew);

            if (!dirOld.Exists() || !dirNew.Exists())
            {
                return DokanError.ErrorPathNotFound;
            }

            var nameOld = Util.GetPathFileName(oldName);
            var nameNew = Util.GetPathFileName(newName);

            if (dirNew.Contains(nameNew))
            {
                return DokanError.ErrorAlreadyExists;
            }

            var inode = dirOld.GetItemINodeIndex(nameOld);
            dirOld.Delete(nameOld);
            dirNew.AddItem(nameNew, inode);

            return DokanError.ErrorSuccess;
        }
开发者ID:WishSummer,项目名称:FS,代码行数:33,代码来源:FSDrive.cs

示例3: DeleteFile

        public DokanError DeleteFile(string fileName, DokanFileInfo info)
        {
            //Console.WriteLine("DeleteFile: {0}", fileName);

            Directory dir = new Directory(Util.GetPathDirectory(fileName));
            if (!dir.Exists())
            {
                return DokanError.ErrorPathNotFound;
            }

            String name = Util.GetPathFileName(fileName);

            if (!dir.Contains(name))
            {
                return DokanError.ErrorFileNotFound;
            }

            dir.Delete(name);
            return DokanError.ErrorSuccess;
        }
开发者ID:WishSummer,项目名称:FS,代码行数:20,代码来源:FSDrive.cs

示例4: DeleteDirectory

        public DokanError DeleteDirectory(string fileName, DokanFileInfo info)
        {
            Directory currentDir = new Directory(fileName);
            if (!currentDir.Exists())
            {
                return DokanError.ErrorPathNotFound;
            }

            // Windows Explorer 将会处理递归删除部分,所以这里不需要处理
            if (currentDir.Count() > 0)
            {
                return DokanError.ErrorDirNotEmpty;
            }

            Directory dir = new Directory(Util.GetPathDirectory(fileName));
            if (!dir.Exists())
            {
                return DokanError.ErrorPathNotFound;
            }

            String name = Util.GetPathFileName(fileName);

            if (!dir.Contains(name))
            {
                return DokanError.ErrorFileNotFound;
            }

            dir.Delete(name);
            return DokanError.ErrorSuccess;
        }
开发者ID:WishSummer,项目名称:FS,代码行数:30,代码来源:FSDrive.cs


注:本文中的Directory.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。