当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryInfo.SubDir方法代码示例

本文整理汇总了C#中System.IO.DirectoryInfo.SubDir方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.SubDir方法的具体用法?C# DirectoryInfo.SubDir怎么用?C# DirectoryInfo.SubDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了DirectoryInfo.SubDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FetchOneFileWithNoBackupOverNetwork

        public void FetchOneFileWithNoBackupOverNetwork()
        {
            // This is a real run (so it is slow), and it will fetch data over the network.
            var d = new DirectoryInfo("FetchOneFileWithNoBackupOverNetwork");
            if (d.Exists)
            {
                d.Delete(true);
            }
            d.Create();

            var c = GenerateLocalConfigWithWorkingRemote(d);
            Locator.DisableAllLocators(true);

            var l = LocalMachine.GetLocation(c);
            var r = l.GetDSInfo("user.gwatts:user.gwatts.301295.EVNT.1");
            Assert.AreEqual(1, l.GetDS(r, rep => Console.WriteLine(rep), fslist => fslist.Take(1).ToArray(), null, 0).Length);

            var dsdir = d.SubDir("user.gwatts.301295.EVNT.1");
            Assert.IsTrue(dsdir.Exists);
            Assert.AreEqual(1, dsdir.EnumerateFiles("*.root.*", SearchOption.AllDirectories).Count());

            // Next, make sure that there are no files left over up on the remote machine.
            var username = c["LinuxUserName"];
            var machine = c["LinuxHost"];

            using (var s = new SSHConnection(machine, username))
            {
                bool stillThere = false;
                s.ExecuteCommand(string.Format("ls {0}", c["LinuxTempLocation"]),
                    outLine =>
                    {
                        Console.WriteLine("output of ls: " + outLine);
                        stillThere |= !outLine.Contains("cannot access");
                    }
                    );
                Assert.IsFalse(stillThere);
            }
        }
开发者ID:LHCAtlas,项目名称:AtlasSSH,代码行数:38,代码来源:LocalMachineTest.cs

示例2: DownloadToLinuxDirectoryThatIsAWindowsDirectoryAndAreadyCreated

        public void DownloadToLinuxDirectoryThatIsAWindowsDirectoryAndAreadyCreated()
        {
            // Seen in the wild. A crash (or other interruption) means the dataset directory has
            // been created, but is empty (for whatever reason). In that particular case, we should
            // treat it as not there.

            var dsinfo = MakeDSInfo("ds1.1.1");
            var d = new DirectoryInfo("DownloadToLinuxDirectoryThatIsAWindowsDirectory");
            if (d.Exists)
            {
                d.Delete(true);
            }
            d.Create();
            var dsdir = d.SubDir(dsinfo.Name);
            dsdir.Create();

            var ld = new LinuxMirrorDownloaderPretend(d, dsinfo.Name);
            var gf = new GRIDFetchToLinuxVisibleOnWindows(d, ld, "/bogus/files/store");
            var r = gf.GetDS(dsinfo);
            Assert.IsNotNull(r);
            Assert.AreEqual(5, r.Length);
            Assert.AreEqual("/bogus/files/store/ds1.1.1", ld.LinuxDest);
        }
开发者ID:LHCAtlas,项目名称:AtlasSSH,代码行数:23,代码来源:GRIDFetchToLinuxVisibleOnWindowsTest.cs

示例3: LoadNewFilesToLocalWhenEmptyDirectory

        public void LoadNewFilesToLocalWhenEmptyDirectory()
        {
            // Seen in the wild. Local directory is actually there for the dataset, but
            // empty due to an earlier crash. Make sure the copy still occurs.

            AtlasWorkFlows.Utils.IPLocationTests.SetIpName("pc.cern.ch");
            var dsname = "ds1.1.1";
            var d1 = utils.BuildSampleDirectoryBeforeBuild("LoadNewFilesToLocalWhenMissingRemote", dsname);
            var d2 = new DirectoryInfo("LoadNewFilesToLocalWhenMissingLocal");
            if (d2.Exists)
            {
                d2.Delete(true);
            }
            d2.Create();
            d2.Refresh();
            d2.SubDir("ds1.1.1").Create();
            Locator._getLocations = () => utils.GetLocal(d1, d2);

            var locator = new Locator();
            var l = locator.FindLocation("MyTestLocalLocation");
            var r = l.GetDSInfo("ds1.1.1");
            Assert.IsFalse(r.IsLocal(null));
            var files = l.GetDS(r, null, null, null, 0);
            Assert.AreEqual(5, files.Length);
            Assert.IsTrue(files[0].LocalPath.Contains("LoadNewFilesToLocalWhenMissingLocal"));
            Assert.AreEqual("ds1.1.1", d2.EnumerateDirectories().First().Name);
        }
开发者ID:LHCAtlas,项目名称:AtlasSSH,代码行数:27,代码来源:LocalMachineTest.cs


注:本文中的System.IO.DirectoryInfo.SubDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。