LogViewer.FileWithPosition.FileNameInFolder C# (CSharp) Method

FileNameInFolder() public method

public FileNameInFolder ( string folder ) : bool
folder string
return bool
        public bool FileNameInFolder(string folder)
        {
            var fullpath = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(folder));
            var filepath = System.IO.Path.GetFullPath(System.IO.Path.GetDirectoryName(FileName));
            return fullpath.Equals(filepath,
                StringComparison.InvariantCultureIgnoreCase);
        }

Usage Example

 public void FileNotInFolder()
 {
     var file = new FileWithPosition(@"C:\Progra~1\someprogram1\somelog.txt");
     Assert.That(!file.FileNameInFolder(@"C:\Program Files\someprogram\"));
     Assert.That(!file.FileNameInFolder(@"C:\Progra~1\someprogram\"));
     var file2 = new FileWithPosition(@"C:\Program Files\someprogram1\somelog.txt");
     Assert.That(!file2.FileNameInFolder(@"C:\Program Files\someprogram\"));
     Assert.That(!file2.FileNameInFolder(@"C:\Progra~1\someprogram\"));
 }