Exemplo n.º 1
0
        public void TestGitHub()
        {
            var file = new ZlpFileInfo(@"C:\Ablage\test.txt");

            file.Directory.CheckCreate();
            file.WriteAllText(@"Ein Test.");

            Assert.DoesNotThrow(() => file.MoveTo(@"C:\Ablage\test2.txt", true));

            file.WriteAllText(@"Ein Test.");
            new DirectoryInfo(@"D:\Ablage").Create();
            Assert.DoesNotThrow(() => file.MoveTo(@"D:\Ablage\test3.txt", true));
        }
Exemplo n.º 2
0
        public void TestGitHub()
        {
            var file = new ZlpFileInfo(@"C:\Ablage\test.txt");

            file.Directory.CheckCreate();
            file.WriteAllText(@"Ein Test.");

            Assert.DoesNotThrow(() => file.MoveTo(@"C:\Ablage\test2.txt", true));

            if (DriveInfo.GetDrives().Any(di => di.Name.StartsWith(@"D:", StringComparison.InvariantCultureIgnoreCase)))
            {
                file.WriteAllText(@"Ein Test.");
                new DirectoryInfo(@"D:\Ablage").Create();
                Assert.DoesNotThrow(() => file.MoveTo(@"D:\Ablage\test3.txt", true));
            }

            new ZlpFileInfo(@"C:\Ablage\test2.txt").Delete();
        }
Exemplo n.º 3
0
        private static void doTest01()
        {
            try
            {
                Console.WriteLine();
                Console.WriteLine();

                const string longFileOnC = @"C:\Ablage\test-only\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\LalalaC.txt";

                var f1 = new ZlpFileInfo(longFileOnC);
                f1.Directory.Create();
                f1.WriteAllText("lalala.");
                Console.WriteLine($"f1.FullName.Length: {f1.FullName.Length}");

                const string longFileOnD = @"D:\Ablage\test-only\Ablage2\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\LalalaD.txt";

                var f2 = new ZlpFileInfo(longFileOnD);
                f2.Directory.Create();

                //f1.MoveTo(f2, true);
                Console.WriteLine($"f2.FullName.Length: {f2.FullName.Length}");

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("sourceFile:");
                Console.WriteLine(f1.FullName);
                Console.WriteLine();
                Console.WriteLine("destinationFile:");
                Console.WriteLine(f2.FullName);

                ZlpIOHelper.MoveFile(f1.FullName, f2.FullName, true);
            }
            finally
            {
                Console.WriteLine();

                const string cAblageTestOnly = @"C:\Ablage\test-only\";
                new ZlpDirectoryInfo(cAblageTestOnly).Delete(true);
                Console.WriteLine($"deleted: {cAblageTestOnly}");

                const string dAblageTestOnly = @"D:\Ablage\test-only\";
                new ZlpDirectoryInfo(dAblageTestOnly).Delete(true);
                Console.WriteLine($"deleted: {dAblageTestOnly}");
            }
        }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            var f1 = new ZlpFileInfo(@"C:\Ablage\test-only\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Lalala.txt");

            f1.Directory.Create();
            f1.WriteAllText("lalala.");
            Console.WriteLine(f1.Length);

            new ZlpDirectoryInfo(@"C:\Ablage\test-only\").Delete(true);
            //f1.MoveToRecycleBin();


            var f = new ZlpFileInfo(@"C:\Ablage\Lalala.txt");

            f.WriteAllText("lalala.");
            f.MoveToRecycleBin();

            var d = new ZlpDirectoryInfo(@"C:\Ablage\LalalaOrdner");

            d.Create();
            d.MoveToRecycleBin();
        }
Exemplo n.º 5
0
        public void TestGeneral()
        {
            var tempFolder = Environment.ExpandEnvironmentVariables("%temp%");

            Assert.True(ZlpIOHelper.DirectoryExists(tempFolder));

            var tempPath = ZlpPathHelper.Combine(tempFolder, "ZlpTest");

            try
            {
                ZlpIOHelper.CreateDirectory(tempPath);
                Assert.IsTrue(ZlpIOHelper.DirectoryExists(tempPath));

                var filePath = ZlpPathHelper.Combine(tempPath, "text.zlp");
                using (var fileHandle = ZlpIOHelper.CreateFileHandle(
                           filePath,
                           CreationDisposition.CreateAlways,
                           FileAccess.GenericWrite | FileAccess.GenericRead,
                           FileShare.None))
                    using (var textStream = new StreamWriter(new FileStream(fileHandle, System.IO.FileAccess.Write)))
                    {
                        textStream.WriteLine("Zeta Long Paths Extended testing...");
                        textStream.Flush();
                        //textStream.Close();
                        //fileHandle.Close();
                    }

                // --

                var filePath2 = new ZlpFileInfo(ZlpPathHelper.Combine(tempPath, "text.test"));
                filePath2.WriteAllText(Guid.NewGuid().ToString(@"N"));

                var infos = new ZlpFileDateInfos
                {
                    LastAccessTime = new DateTime(2010, 03, 04),
                    LastWriteTime  = new DateTime(2011, 04, 05),
                    CreationTime   = new DateTime(2012, 05, 06)
                };

                filePath2.DateInfos = infos;

                var infos2 = filePath2.DateInfos;

                Assert.IsTrue(infos.LastAccessTime == infos2.LastAccessTime);
                Assert.IsTrue(infos.LastWriteTime == infos2.LastWriteTime);
                Assert.IsTrue(infos.CreationTime == infos2.CreationTime);

                // --

                Assert.IsTrue(ZlpIOHelper.FileExists(filePath));


                var m = ZlpIOHelper.GetFileLength(filePath);
                Assert.IsTrue(m > 0);
                Assert.IsTrue(m == new FileInfo(filePath).Length);


                Assert.IsTrue(ZlpIOHelper.FileExists(@"c:\Windows\notepad.exe"));
                Assert.IsFalse(ZlpIOHelper.FileExists(@"c:\dslfsdjklfhsd\kjsaklfjd.exe"));
                Assert.IsFalse(ZlpIOHelper.FileExists(@"c:\ablage"));

                Assert.IsFalse(ZlpIOHelper.DirectoryExists(@"c:\Windows\notepad.exe"));
                Assert.IsTrue(ZlpIOHelper.DirectoryExists(@"c:\Windows"));
                Assert.IsTrue(ZlpIOHelper.DirectoryExists(@"c:\Windows\"));
                Assert.IsFalse(ZlpIOHelper.DirectoryExists(@"c:\fkjhskfsdhfjkhsdjkfhsdkjfh"));
                Assert.IsFalse(ZlpIOHelper.DirectoryExists(@"c:\fkjhskfsdhfjkhsdjkfhsdkjfh\"));

                // --

                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileLastWriteTime(filePath, new DateTime(1986, 1, 1)));
                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileLastAccessTime(filePath, new DateTime(1987, 1, 1)));
                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileCreationTime(filePath, new DateTime(1988, 1, 1)));

                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileLastWriteTime(tempPath, new DateTime(1986, 1, 1)));
                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileLastAccessTime(tempPath, new DateTime(1987, 1, 1)));
                Assert.DoesNotThrow(() => ZlpIOHelper.SetFileCreationTime(tempPath, new DateTime(1988, 1, 1)));

                var anotherFile = ZlpPathHelper.Combine(tempPath, "test2.zpl");
                ZlpIOHelper.WriteAllText(anotherFile, @"äöü.");
                Assert.IsTrue(ZlpIOHelper.FileExists(anotherFile));

                var time = ZlpIOHelper.GetFileLastWriteTime(filePath);
                Assert.Greater(time, DateTime.MinValue);

                var owner = ZlpIOHelper.GetFileOwner(@"c:\Windows\notepad.exe");
                Assert.IsNotEmpty(owner ?? string.Empty);

                var l = ZlpIOHelper.GetFileLength(anotherFile);
                Assert.IsTrue(l > 0);
            }
            finally
            {
                ZlpIOHelper.DeleteDirectory(tempPath, true);
            }
        }
Exemplo n.º 6
0
        private static void Main(string[] args)
        {
            const string name = @"D:\SomeStuff\Name Space\More.Stuff\Test";

            var dirInfo5 = new ZlpDirectoryInfo(name);

            Console.WriteLine($@"'{dirInfo5.Name}'.");

            var dirInfo6 = new DirectoryInfo(name);

            Console.WriteLine($@"'{dirInfo6.Name}'.");

            if (dirInfo5.Name != dirInfo6.Name)
            {
                throw new Exception(@"5-6");
            }

            // --

            var dirInfo1 = new ZlpDirectoryInfo(@"C:\Foo\Bar");

            Console.WriteLine(dirInfo1.Name); //"Bar"
            var dirInfo2 = new ZlpDirectoryInfo(@"C:\Foo\Bar\");

            Console.WriteLine(dirInfo2.Name); //"", an empty string

            var dirInfo3 = new DirectoryInfo(@"C:\Foo\Bar");

            Console.WriteLine(dirInfo1.Name);
            var dirInfo4 = new DirectoryInfo(@"C:\Foo\Bar\");

            Console.WriteLine(dirInfo2.Name);

            if (dirInfo1.Name != dirInfo3.Name)
            {
                throw new Exception(@"1-3");
            }
            if (dirInfo2.Name != dirInfo4.Name)
            {
                throw new Exception(@"2-4");
            }

            // --

            var f1 = new ZlpFileInfo(
                @"C:\Ablage\test-only\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Ablage\Lalala.txt");

            f1.Directory.Create();
            f1.WriteAllText("lalala.");
            Console.WriteLine(f1.Length);

            new ZlpDirectoryInfo(@"C:\Ablage\test-only\").Delete(true);
            //f1.MoveToRecycleBin();


            var f = new ZlpFileInfo(@"C:\Ablage\Lalala.txt");

            f.WriteAllText("lalala.");
            f.MoveToRecycleBin();

            var d = new ZlpDirectoryInfo(@"C:\Ablage\LalalaOrdner");

            d.Create();
            d.MoveToRecycleBin();
        }