Exemple #1
0
        public void DeleteFile(string filePath)
        {
            string folderPath;
            string fileName;

            if (FileSystemObject.IsPathSystemRooted(filePath))
            {
                filePath = filePath.ForwardSlashes();

                if (filePath.StartsWith(folderHierarchy.ProjectRoot))
                {
                    filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.Root);
                }
                else if (filePath.StartsWith(folderHierarchy.ServicesRoot))
                {
                    filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.Root);

                    if (FileSystemObject.IsPathSystemRooted(filePath))
                    {
                        filePath = FileSystemObject.BluntStart(filePath, folderHierarchy.ServicesRoot);
                    }
                }
            }

            folderPath = Path.GetDirectoryName(filePath);
            folderPath = folderPath.ForwardSlashes();

            fileName = Path.GetFileName(filePath);

            if (folderHierarchy.FileSystem.Exists(filePath))
            {
                var folder = (Folder)folderHierarchy.FileSystem[folderPath];
                var file   = (File)folderHierarchy.FileSystem[filePath];

                folder.Files.Remove(file);
            }
        }
 public FileSystemObjects(FileSystemObject fileSystemObject, ApplicationFolderHierarchy folderHierarchy)
 {
     this.folderHierarchy  = folderHierarchy;
     this.fileSystemObject = fileSystemObject;
 }