public void TestGeneral2() { var s1 = @"C:\Users\ukeim\Documents\Visual Studio 2008\Projects\Zeta Producer 9\Zeta Producer Main\Deploy\Origin\Enterprise\C-Allgaier\Windows\Packaging\Stationary\DEU\FirstStart\StandardProject"; var s2 = Path.GetFullPath(s1); Assert.AreEqual( @"C:\Users\ukeim\Documents\Visual Studio 2008\Projects\Zeta Producer 9\Zeta Producer Main\Deploy\Origin\Enterprise\C-Allgaier\Windows\Packaging\Stationary\DEU\FirstStart\StandardProject", s2); // -- s1 = @"c:\ablage\..\windows\notepad.exe"; s2 = Path.GetFullPath(s1); Assert.AreEqual(@"c:\windows\notepad.exe", s2); //-- s1 = @"lalala-123"; s2 = Path.GetFileNameWithoutExtension(s1); Assert.AreEqual(@"lalala-123", s2); //-- s1 = @"lalala-123.txt"; s2 = Path.GetFileNameWithoutExtension(s1); Assert.AreEqual(@"lalala-123", s2); //-- s1 = @"C:\Ablage\lalala-123.txt"; s2 = Path.GetFileNameWithoutExtension(s1); Assert.AreEqual(@"lalala-123", s2); //-- s1 = @"\\nas001\data\folder\lalala-123.txt"; s2 = Path.GetFileNameWithoutExtension(s1); Assert.AreEqual(@"lalala-123", s2); //-- s1 = @"c:\ablage\..\windows\notepad.exe"; s2 = Path.GetFileNameWithoutExtension(s1); Assert.AreEqual(@"notepad", s2); //-- s1 = @"c:\ablage\..\windows\notepad.exe"; s2 = ZspPathHelper.GetExtension(s1); Assert.AreEqual(@".exe", s2); //-- //-- s1 = @"c:\ablage\..\windows\notepad.file.exe"; s2 = ZspPathHelper.GetExtension(s1); Assert.AreEqual(@".exe", s2); //-- s1 = @"c:\ablage\..\windows\notepad.exe"; s2 = ZspPathHelper.ChangeExtension(s1, @".com"); Assert.AreEqual(@"c:\ablage\..\windows\notepad.com", s2); // -- s1 = @"file.ext"; s2 = @"c:\ablage\path1\path2"; var s3 = @"c:\ablage\path1\path2\file.ext"; var s4 = ZspPathHelper.GetAbsolutePath(s1, s2); Assert.AreEqual(s3, s4); var s5 = s1.MakeAbsoluteTo(new DirectoryInfo(s2)); Assert.AreEqual(s3, s5); // -- s1 = @"c:\folder1\folder2\folder4\"; s2 = @"c:\folder1\folder2\folder3\file1.txt"; s3 = ZspPathHelper.GetRelativePath(s1, s2); s4 = @"..\folder3\file1.txt"; Assert.AreEqual(s3, s4); }
public void TestGeneral() { // Ordner mit Punkt am Ende. var dir = $@"C:\Ablage\{Guid.NewGuid():N}."; Assert.IsFalse(new DirectoryInfo(dir).Exists); new DirectoryInfo(dir).CheckCreate(); Assert.IsTrue(new DirectoryInfo(dir).Exists); new DirectoryInfo(dir).Delete(true); Assert.IsFalse(new DirectoryInfo(dir).Exists); //Assert.IsTrue(new DirectoryInfo(Path.GetTempPath()).CreationTime>DateTime.MinValue); //Assert.IsTrue(new DirectoryInfo(Path.GetTempPath()).Exists); //Assert.IsFalse(new DirectoryInfo(@"C:\Ablage\doesnotexistjdlkfjsdlkfj").Exists); //Assert.IsTrue(new DirectoryInfo(Path.GetTempPath()).Exists); //Assert.IsFalse(new DirectoryInfo(@"C:\Ablage\doesnotexistjdlkfjsdlkfj2").Exists); //Assert.IsFalse(new DirectoryInfo(@"\\zetac11\C$\Ablage").Exists); //Assert.IsFalse(new DirectoryInfo(@"\\zetac11\C$\Ablage\doesnotexistjdlkfjsdlkfj2").Exists); const string s1 = @"C:\Users\Chris\Documents\Development\ADC\InterStore.NET\Visual Studio 2008\6.4.2\Zeta Resource Editor"; const string s2 = @"C:\Users\Chris\Documents\Development\ADC\InterStore.NET\Visual Studio 2008\6.4.2\Web\central\Controls\App_LocalResources\ItemSearch"; var s3 = ZspPathHelper.GetRelativePath(s1, s2); Assert.AreEqual(s3, @"..\Web\central\Controls\App_LocalResources\ItemSearch"); var ext = ZspPathHelper.GetExtension(s3); Assert.AreEqual(ext ?? string.Empty, string.Empty); ext = ZspPathHelper.GetExtension(@"C:\Ablage\Uwe.txt"); Assert.AreEqual(ext, @".txt"); const string path = @"C:\Ablage\Test"; Assert.AreEqual( new DirectoryInfo(path).Name, new DirectoryInfo(path).Name); Assert.AreEqual( new DirectoryInfo(path).FullName, new DirectoryInfo(path).FullName); const string filePath = @"C:\Ablage\Test\file.txt"; var fn1 = new FileInfo(filePath).Directory?.FullName; var fn2 = new FileInfo(filePath).Directory.FullName; var fn1A = new FileInfo(filePath).DirectoryName; var fn2A = new FileInfo(filePath).DirectoryName; Assert.AreEqual(fn1, fn2); Assert.AreEqual(fn1A, fn2A); var fn = new DirectoryInfo(@"\\zetac11\C$\Ablage\doesnotexistjdlkfjsdlkfj2").Parent.FullName; Assert.AreEqual(fn, @"\\zetac11\C$\Ablage"); fn = new DirectoryInfo(@"\\zetac11\C$\Ablage\doesnotexistjdlkfjsdlkfj2\").Parent.FullName; Assert.AreEqual(fn, @"\\zetac11\C$\Ablage"); }