public void 左辺がnullでも等号演算子で比較できる()
        {
            PathInfo basePathInfo = null;
            PathInfo compareToPathInfo = new PathInfo(@"C:\");

            Assert.IsFalse(basePathInfo == compareToPathInfo);
        }
Esempio n. 2
0
        public void ディレクトリをコピーする()
        {
            PathInfo startupPath = new PathInfo(System.Windows.Forms.Application.StartupPath);

            PathInfo newDirectory1 = startupPath.Combine("NewDirectory1");
            PathInfo newDirectory1InFile = newDirectory1.Combine("NewDirectory1File.txt");
            PathInfo newDirectory2 = startupPath.Combine("NewDirectory2");
            PathInfo newDirectory2InFile = newDirectory2.Combine("NewDirectory1File.txt");

            try
            {
                System.IO.Directory.CreateDirectory(newDirectory1.FullPath);
                using (System.IO.File.Create(newDirectory1InFile.FullPath))
                {
                }

                newDirectory1.Copy(newDirectory2);

                Assert.AreEqual(PathInfo.PathType.Directory, newDirectory2.Type);
                Assert.AreEqual(PathInfo.PathType.File, newDirectory2InFile.Type);
            }
            finally
            {
                if (newDirectory1.Type != PathInfo.PathType.UnExists)
                {
                    newDirectory1.Delete();
                }
                if (newDirectory2.Type != PathInfo.PathType.UnExists)
                {
                    newDirectory2.Delete();
                }
            }
        }
        public void 右辺がnullでも不等号演算子で比較できる()
        {
            PathInfo basePathInfo = new PathInfo(@"C:\");
            PathInfo compareToPathInfo = null;

            Assert.IsTrue(basePathInfo != compareToPathInfo);
        }
Esempio n. 4
0
        public void ファイルを移動する()
        {
            PathInfo startupPath = new PathInfo(System.Windows.Forms.Application.StartupPath);

            PathInfo path = startupPath.Combine("test.conf");

            PathInfo copyPath = startupPath.Combine("copytest.conf");
            PathInfo movePath = startupPath.Combine("movetest.conf");

            try
            {
                path.Copy(copyPath);

                copyPath.Move(movePath);

                Assert.AreEqual(PathInfo.PathType.UnExists, copyPath.Type);
                Assert.AreEqual(PathInfo.PathType.File, movePath.Type);
            }
            finally
            {
                if (copyPath.Type != PathInfo.PathType.UnExists)
                {
                    copyPath.Delete();
                }

                if (movePath.Type != PathInfo.PathType.UnExists)
                {
                    movePath.Delete();
                }
            }
        }
Esempio n. 5
0
        public void 連結したパスが取得できる()
        {
            PathInfo target = new PathInfo(System.Windows.Forms.Application.StartupPath);

            PathInfo actual = target.Combine("A", "test.conf");
            string path = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "A","test.conf");

            Assert.AreEqual(path, actual.FullPath);
        }
 /// <summary>
 /// 指定したファイルパスをクリップボードにコピーします。
 /// </summary>
 /// <param name="copies">コピーするファイルパス</param>
 public static void Copy(PathInfo[] copies)
 {
     StringCollection list = new StringCollection();
     foreach (PathInfo path in copies)
     {
         list.Add(path.FullPath);
     }
     //クリップボードにコピーする
     Clipboard.SetFileDropList(list);
 }
Esempio n. 7
0
        public void マイコンピュータはドライブの一覧を取得する()
        {
            PathInfo[] actuals = new PathInfo("%MyComputer%").GetChildren();

            DriveInfo[] driveInfos = DriveInfo.GetDrives();
            for (int i = 0; i < driveInfos.Length; i++)
            {
                Assert.AreEqual(actuals[i].FullPath, driveInfos[i].Name);
            }
        }
Esempio n. 8
0
        public void ファイルが削除される()
        {
            PathInfo startupPath = new PathInfo(System.Windows.Forms.Application.StartupPath);
            PathInfo copyPath = startupPath.Combine("testForCopy.conf");

            startupPath.Combine("test.conf").Copy(copyPath);
            Assert.AreEqual(PathInfo.PathType.File, copyPath.Type);

            copyPath.Delete();
            Assert.AreEqual(PathInfo.PathType.UnExists, copyPath.Type);
        }
Esempio n. 9
0
        public void ディレクトリが削除される()
        {
            PathInfo startupPath = new PathInfo(System.Windows.Forms.Application.StartupPath);
            PathInfo copyPath = startupPath.Combine("frameworkForCopy");

            startupPath.Combine("framework").Copy(copyPath);
            Assert.AreEqual(PathInfo.PathType.Directory, copyPath.Type);

            copyPath.Delete();
            Assert.AreEqual(PathInfo.PathType.UnExists, copyPath.Type);
        }
Esempio n. 10
0
        public void ディレクトリの中の要素を取得する()
        {
            PathInfo[] actual = new PathInfo(Application.StartupPath).GetChildren();

            Assert.AreEqual("framework", actual[0].Name);
            Assert.AreEqual("lib", actual[1].Name);
            Assert.AreEqual("tests", actual[2].Name);

            Assert.AreEqual("agent.conf", actual[3].Name);
            Assert.AreEqual("agent.log.conf", actual[4].Name);
            Assert.AreEqual("launcher.log.conf", actual[5].Name);
            Assert.AreEqual("nunit-agent-x86.exe", actual[6].Name);
            Assert.AreEqual("nunit-agent-x86.exe.config", actual[7].Name);
            Assert.AreEqual("nunit-agent.exe", actual[8].Name);
            Assert.AreEqual("nunit-agent.exe.config", actual[9].Name);
            Assert.AreEqual("nunit-console-x86.exe", actual[10].Name);
            Assert.AreEqual("nunit-console-x86.exe.config", actual[11].Name);
            Assert.AreEqual("nunit-console.exe", actual[12].Name);
            Assert.AreEqual("nunit-console.exe.config", actual[13].Name);
            Assert.AreEqual("nunit-editor.exe", actual[14].Name);
            Assert.AreEqual("nunit-x86.exe", actual[15].Name);
            Assert.AreEqual("nunit-x86.exe.config", actual[16].Name);
            Assert.AreEqual("nunit.exe", actual[17].Name);
            Assert.AreEqual("nunit.exe.config", actual[18].Name);
            Assert.AreEqual("nunit.framework.dll", actual[19].Name);
            Assert.AreEqual("NUnitFitTests.html", actual[20].Name);
            Assert.AreEqual("NUnitTests.config", actual[21].Name);
            Assert.AreEqual("NUnitTests.nunit", actual[22].Name);
            Assert.AreEqual("NUnitTests.VisualState.xml", actual[23].Name);
            Assert.AreEqual("pnunit-agent.exe", actual[24].Name);
            Assert.AreEqual("pnunit-agent.exe.config", actual[25].Name);
            Assert.AreEqual("pnunit-launcher.exe", actual[26].Name);
            Assert.AreEqual("pnunit-launcher.exe.config", actual[27].Name);
            Assert.AreEqual("pnunit.framework.dll", actual[28].Name);
            Assert.AreEqual("pnunit.tests.dll", actual[29].Name);
            Assert.AreEqual("runpnunit.bat", actual[30].Name);
            Assert.AreEqual("test.conf", actual[31].Name);
        }
Esempio n. 11
0
 public void objectにボクシングしても比較できる()
 {
     object boxing = new PathInfo(@"c:\");
     Assert.IsTrue(new PathInfo(@"C:\").Equals(boxing));
 }
        private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.EditAction == DataGridEditAction.Cancel)
            {
                return;
            }
            PathInfo elementPath = this.DataGridWrapperModelExtender.GetDataContext(e.Row);

            if (elementPath == null)
            {
                return;
            }

            TextBox renamedTextBox = e.EditingElement as TextBox;

            PathInfo renamedPath = new PathInfo(Path.Combine(elementPath.ParentDirectory.FullPath, renamedTextBox.Text));
            if (elementPath.Type == PathInfo.PathType.Directory)
            {
                Directory.Move(elementPath.FullPath, renamedPath.FullPath);
            }
            else if (elementPath.Type == PathInfo.PathType.File)
            {
                File.Move(elementPath.FullPath, renamedPath.FullPath);
            }

            this.DataGridWrapperModelExtender.SetDataContext(e.Row, renamedPath);
            this.DataGridEditExtender.EndEdit();
        }
        private void addressBar_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.Down))
            {
                this.dataGrid.FocusFirstCell();
            }
            else if (Keyboard.IsKeyDown(Key.Enter))
            {
                if (this.IsSearchModeAtAddressBar == true)
                {
                    this.FilterDataGrid();

                    e.Handled = true;
                    return;
                }

                PathInfo processPath = new PathInfo(this.addressBar.Text.Trim());

                this.ExecuteDataGridSelectedPathes(processPath);

                if (processPath.Type == PathInfo.PathType.File)
                {
                    this.ExecuteDataGridSelectedPathes(processPath.ParentDirectory);
                }
                e.Handled = true;
            }
        }
Esempio n. 14
0
 /// <summary>
 /// パスを移動します。
 /// </summary>
 /// <param name="moveTo">移動先</param>
 public void Move(PathInfo moveTo)
 {
     if (this.Type == PathType.File)
     {
         File.Move(this.FullPath, moveTo.FullPath);
     }
     else if (this.Type == PathType.Directory)
     {
         Directory.Move(this.FullPath, moveTo.FullPath);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// 指定したファイルパスにコピーします
        /// </summary>
        /// <param name="destination">コピー先のファイル</param>
        public void Copy(PathInfo destination)
        {
            if (this.Type == PathType.File)
            {
                File.Copy(this.FullPath, destination.FullPath);
            }
            else if (this.Type == PathType.Directory)
            {
                //コピー先のディレクトリがないときは作る
                if (destination.Type == PathType.UnExists)
                {
                    System.IO.Directory.CreateDirectory(destination.FullPath);
                    //属性もコピー
                    System.IO.File.SetAttributes(destination.FullPath,
                        System.IO.File.GetAttributes(this.FullPath));
                }

                foreach (PathInfo path in this.GetChildren())
                {
                    path.Copy(destination.Combine(path.Name));
                }
            }
        }
Esempio n. 16
0
 public void objectにボクシングしても同じハッシュ値が取得できる()
 {
     object boxing = new PathInfo(@"c:\");
     Assert.IsTrue(new PathInfo(@"C:\").GetHashCode() == boxing.GetHashCode());
 }
Esempio n. 17
0
        /// <summary>
        /// 指定したファイルパスをクリップボードに切り取ります。
        /// </summary>
        /// <param name="cuts">切り取るファイルパス</param>
        public static void Cut(PathInfo[] cuts)
        {
            string[] pathes = cuts.Select(path => path.FullPath).ToArray();

            //ファイルドロップ形式のDataObjectを作成する
            IDataObject data = new DataObject(DataFormats.FileDrop, pathes);

            //DragDropEffects.Moveを設定する(DragDropEffects.Move は 2)
            byte[] bs = new byte[] { (byte)DragDropEffects.Move, 0, 0, 0 };
            MemoryStream ms = new MemoryStream(bs);
            data.SetData(PreferredDropEffect, ms);

            //クリップボードに切り取る
            Clipboard.SetDataObject(data);
        }