public void GetDefaultDrive() { // Get the default drive's path var drivePath = new System.IO.DirectoryInfo(Environment.SystemDirectory).Root.Name; var driveInfoPath = new System.IO.DriveInfo(drivePath); Assert.IsTrue(drivePath != null); var drive = BrowseItemFromPath.InitItem(drivePath); //// drive.LoadProperties(); Assert.IsTrue(drive != null); Assert.IsTrue(drivePath.Equals(drive.PathFileSystem, StringComparison.InvariantCulture)); Assert.IsFalse(string.IsNullOrEmpty(drive.Name)); //Assert.IsTrue(string.Compare(drive.Name, driveInfoPath.VolumeLabel, true) == 0); Assert.IsTrue(string.Compare(drive.ParseName, driveInfoPath.Name, true) == 0); Assert.IsFalse(string.IsNullOrEmpty(drive.LabelName)); Assert.IsFalse(drive.IsSpecialParseItem); Assert.IsTrue(string.IsNullOrEmpty(drive.PathSpecialItemId)); Assert.IsTrue(string.Compare(drive.ParseName, drive.PathFileSystem, true) == 0); //// Assert.IsTrue((drive.ItemType & DirectoryItemFlags.FileSystemDirectory) != 0); //// Assert.IsTrue((drive.ItemType & DirectoryItemFlags.Drive) != 0); //// Assert.IsTrue(drive.ParentIdList.Size > 0); //// Assert.IsTrue(drive.ChildIdList.Size > 0); //// Assert.IsFalse(string.IsNullOrEmpty(drive.IconResourceId)); }
public void GetMusic() { var music = BrowseItemFromPath.InitItem(KF_IID.ID_FOLDERID_Music); //// music.LoadProperties(); Assert.IsTrue(music != null); //// Assert.IsFalse(string.IsNullOrEmpty(music.IconResourceId)); //// Assert.IsTrue(music.IconResourceId.IndexOf(',') > 0); Assert.IsFalse(string.IsNullOrEmpty(music.Name)); Assert.IsFalse(string.IsNullOrEmpty(music.PathFileSystem)); Assert.IsTrue(music.IsSpecialParseItem); Assert.IsTrue(string.Compare(music.PathSpecialItemId, KF_IID.ID_FOLDERID_Music, true) == 0); //// Assert.IsTrue(music.KnownFolder != null); //// Assert.IsTrue(string.Compare(music.PathSpecialItemId, music.KnownFolder.ParsingName, true) != 0); //// Assert.IsTrue(music.KnownFolder.FolderId == new Guid(KF_ID.ID_FOLDERID_Music)); //// Assert.IsTrue((music.ItemType & DirectoryItemFlags.Special) != 0); //// Assert.IsTrue((music.ItemType & DirectoryItemFlags.FileSystemDirectory) != 0); //// Assert.IsTrue(music.ParentIdList != null); //// Assert.IsTrue(music.ParentIdList.Size >= 1); //// Assert.IsTrue(music.ChildIdList != null); //// Assert.IsTrue(music.ParentIdList.Size >= 1); }
public void GetThisPC() { string id = null; using (var kf = KnownFolderHelper.FromCanonicalName("MyComputerFolder")) { Assert.IsTrue(kf != null); id = kf.GetId(); } Assert.IsTrue(id != null); // file system representation // Lets test the directory browser object with that path var specialItem = BrowseItemFromPath.InitItem(KF_ParseName_IID.MyComputerFolder); //// specialItem.LoadProperties(); Assert.IsTrue(specialItem != null); Assert.IsTrue(specialItem.IsSpecialParseItem == true); Assert.IsTrue(string.IsNullOrEmpty(specialItem.PathSpecialItemId) == false); //// Assert.IsTrue(specialItem.KnownFolder != null); //// Assert.IsTrue(string.Compare(KF_ParseName_IID.MyComputerFolder, specialItem.KnownFolder.ParsingName, true) == 0); //// Assert.IsTrue(string.Compare(specialItem.ParseName, specialItem.KnownFolder.ParsingName, true) == 0); // This item should be the Guid of the 'This PC' special folder //// Assert.IsTrue(specialItem.KnownFolder.FolderId == new Guid(KF_ID.ID_FOLDERID_ComputerFolder)); Assert.IsTrue(string.IsNullOrEmpty(specialItem.PathFileSystem)); Assert.IsFalse(string.IsNullOrEmpty(specialItem.Name)); Assert.IsTrue(string.Compare(specialItem.LabelName, specialItem.Name) == 0); //// Assert.IsTrue((specialItem.ItemType & DirectoryItemFlags.FileSystemDirectory) == 0); //// Assert.IsTrue((specialItem.ItemType & DirectoryItemFlags.SpecialDesktopFileSystemDirectory) != 0); // Not Special as far as parsing name is concerned but a KnownFolder it is. //// Assert.IsTrue((specialItem.ItemType & DirectoryItemFlags.Special) != 0); //// Assert.IsTrue(specialItem.ParentIdList.Size == 0); //// Assert.IsTrue(specialItem.ChildIdList.Size > 0); //// Assert.IsFalse(string.IsNullOrEmpty(specialItem.IconResourceId)); }
public void GetDirectory() { string dirPath = null; using (var kf = KnownFolderHelper.FromCanonicalName("Windows")) { Assert.IsTrue(kf != null); dirPath = kf.GetPath(); } Assert.IsTrue(dirPath != null); // Lets test the directory browser object with that path var dir = BrowseItemFromPath.InitItem(dirPath); //// dir.LoadProperties(); Assert.IsTrue(dir != null); Assert.IsTrue(dir.IsSpecialParseItem == false); Assert.IsTrue(string.IsNullOrEmpty(dir.PathSpecialItemId)); //// Assert.IsTrue(dir.KnownFolder != null); // This item should have the Guid of the 'Windows' special folder //// var dirFolderGuid = new Guid(KF_ID.ID_FOLDERID_Windows); //// Assert.IsTrue(dirFolderGuid == dir.KnownFolder.FolderId); Assert.IsTrue(string.Compare(dirPath, dir.PathFileSystem, true) == 0); Assert.IsFalse(string.IsNullOrEmpty(dir.Name)); Assert.IsTrue(string.Compare(dir.Name, dir.LabelName) == 0); Assert.IsTrue(string.Compare(dir.ParseName, dir.PathFileSystem) == 0); //// Assert.IsTrue((dir.ItemType & DirectoryItemFlags.FileSystemDirectory) != 0); // Not Special as far as parsing name is concerned but a KnownFolder it is. //// Assert.IsTrue((dir.ItemType & DirectoryItemFlags.Special) == 0); //// Assert.IsTrue(dir.ParentIdList.Size > 0); //// Assert.IsTrue(dir.ChildIdList.Size > 0); //// Assert.IsFalse(string.IsNullOrEmpty(dir.IconResourceId)); }