コード例 #1
0
        public void TestMoveTo()
        {
            var tempLongPathFilename     = new StringBuilder(uncDirectory).Append(@"\").Append("file21.ext").ToString();
            var tempDestLongPathFilename = new StringBuilder(uncDirectory).Append(@"\").Append("file21-1.ext").ToString();

            Assert.IsFalse(Pri.LongPath.File.Exists(tempLongPathFilename));
            Pri.LongPath.File.Copy(filePath, tempLongPathFilename);

            try {
                Assert.IsTrue(Pri.LongPath.File.Exists(tempLongPathFilename));

                var fi = new FileInfo(tempLongPathFilename);
                fi.MoveTo(tempDestLongPathFilename);

                try {
                    Assert.IsFalse(Pri.LongPath.File.Exists(tempLongPathFilename));
                    Assert.IsTrue(Pri.LongPath.File.Exists(tempDestLongPathFilename));
                }
                finally {
                    Pri.LongPath.File.Delete(tempDestLongPathFilename);
                }
            }
            finally {
                if (Pri.LongPath.File.Exists(tempLongPathFilename))
                {
                    Pri.LongPath.File.Delete(tempLongPathFilename);
                }
            }
        }