public ProjectFile GetFile(int projectId, int fileId) { try { var file = ProjectFiles.Where <ProjectFile>(p => p.FileID == fileId && p.ProjectID == projectId).FirstOrDefault(); return(file); } catch (Exception) { throw; } }
private void btnRemoveKeywords_Click(object sender, RoutedEventArgs e) { txtRemoveKeywords.Text.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) .ToList() .ForEach(kw => { var keyword = kw.Trim(); if (keyword.Length == 0) { return; } var tobeRemvoe = ProjectFiles.Where(z => z.FileName.Contains(keyword, StringComparison.OrdinalIgnoreCase)).ToList(); tobeRemvoe.ForEach(z => ProjectFiles.Remove(z)); }); }
/// <summary> /// Gets all directories files inside a specific directory. /// </summary> /// <param name = "directory">The path of the directory.</param> /// <param name = "useRelativePath">Indicates whether the specified path is a relative hint path or not.</param> public string[] GetDirectoriesInDirectory(string directory, bool useRelativePath) { var directoryPath = useRelativePath ? new FilePath(this.FilePath.ParentDirectory.FullPath, directory).FullPath : directory; var files = ProjectFiles.Where(x => x.FilePath.ParentDirectory.ParentDirectory.FullPath == directoryPath); var directories = new List <string>(); foreach (var file in files) { var relativePath = file.FilePath.ParentDirectory.GetRelativePath(directoryPath); if (!directories.Contains(relativePath)) { directories.Add(relativePath); } } return(directories.ToArray()); }
/// <summary> /// Gets all project files inside a specific directory. /// </summary> /// <param name = "directory">The path of the directory.</param> /// <param name = "useRelativePath">Indicates whether the specified path is a relative hint path or not.</param> /// <param name="searchSubDirectories">Indicates whether sub directories should be included in the search.</param> public ProjectFileEntry[] GetProjectFilesInDirectory(string directory, bool useRelativePath, bool searchSubDirectories) { var directoryPath = useRelativePath ? new FilePath(this.FilePath.ParentDirectory.FullPath, directory).FullPath : directory; return(ProjectFiles.Where(x => searchSubDirectories ? x.FilePath.ParentDirectory.FullPath.StartsWith(directoryPath) : x.FilePath.ParentDirectory.FullPath == directoryPath).ToArray()); }