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


C# DirectoryInfo.Contains方法代码示例

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


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

示例1: SyncDirs

        static int SyncDirs(string sourceDir, string destDir, bool onlyLog = true)
        {
            int totalDirs = 0;
            if (!Directory.Exists(sourceDir))
            {
                Console.WriteLine("Dir not exist: " + sourceDir);
                return totalDirs;
            }
            if (!Directory.Exists(destDir))
            {
                Console.WriteLine("Dir not exist: " + destDir);
                return totalDirs;
            }

            var destDirs = new DirectoryInfo(destDir).GetDirectories().Select(d => d.Name).ToList();
            foreach(var sourceDirName in (new DirectoryInfo(sourceDir).GetDirectories()))
            {
                if (!destDirs.Contains(sourceDirName.Name))
                {
                    totalDirs++;
                    string newDir = Path.Combine(destDir, sourceDirName.Name);
                    if (onlyLog)
                    {
                        Console.WriteLine("Create dir {0}?", newDir);
                    }else
                    {
                        Console.WriteLine("Create dir {0}", newDir);
                        Directory.CreateDirectory(newDir);
                    }
                }
            }
            return totalDirs;
        }
开发者ID:Guzzter,项目名称:CmdLineTools,代码行数:33,代码来源:Program.cs

示例2: CopyDllsForDomainLoadingDebug

        /// <summary>
        /// This is required for debugging as NHibernate needs to load the DLLs and seems to only look in the current folder.
        /// When run live it will be run via powershell which will put the EXE in the destination folder.
        /// Debugging will have to be run through here, NHMigrate will not work correctly.
        /// </summary>
        /// <param name="projectFolder"></param>
        private void CopyDllsForDomainLoadingDebug(string projectFolder)
        {
            var projectDirectory = new DirectoryInfo(projectFolder);

            var executingBinFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6);

            var currentFilesInDestination = new DirectoryInfo(executingBinFolder).GetFiles("*.dll").Select(f => f.Name).ToList();
            var dlls = projectDirectory.GetFiles("*.dll");

            foreach (var fileInfo in dlls)
            {
                var destFileName = Path.Combine(executingBinFolder, fileInfo.Name);

                if (currentFilesInDestination.Contains(fileInfo.Name))
                {
                    try
                    {
                        File.Delete(destFileName);
                    }
                    catch (Exception)
                    {
                        //try and delete the old files, ignore errors
                    }
                };

                File.Copy(fileInfo.FullName, destFileName);
            }
        }
开发者ID:twistedtwig,项目名称:NHibernateRepository,代码行数:34,代码来源:Program.cs

示例3: IsContainedWithin

 /// <summary>
 /// Determines if the file or directory is contained within the the other directory at any depth.
 /// </summary>
 public static bool IsContainedWithin(this FileSystemInfo fileOrDirectory, DirectoryInfo otherDir)
 {
     return otherDir.Contains(fileOrDirectory);
 }
开发者ID:thomas-parrish,项目名称:Common,代码行数:7,代码来源:FileSystemExtensions.cs

示例4: ApplyDeltaPackage

        public ReleasePackage ApplyDeltaPackage(ReleasePackage basePackage, ReleasePackage deltaPackage, string outputFile)
        {
            Contract.Requires(deltaPackage != null);
            Contract.Requires(!String.IsNullOrEmpty(outputFile) && !File.Exists(outputFile));

            string workingPath;
            string deltaPath;

            using (Utility.WithTempDirectory(out deltaPath, localAppDirectory))
            using (Utility.WithTempDirectory(out workingPath, localAppDirectory)) {
                var fz = new FastZip();
                fz.ExtractZip(deltaPackage.InputPackageFile, deltaPath, null);
                fz.ExtractZip(basePackage.InputPackageFile, workingPath, null);

                var pathsVisited = new List<string>();

                var deltaPathRelativePaths = new DirectoryInfo(deltaPath).GetAllFilesRecursively()
                    .Select(x => x.FullName.Replace(deltaPath + Path.DirectorySeparatorChar, ""))
                    .ToArray();

                // Apply all of the .diff files
                deltaPathRelativePaths
                    .Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
                    .Where(x => !x.EndsWith(".shasum", StringComparison.InvariantCultureIgnoreCase))
                    .Where(x => !x.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase) ||
                                !deltaPathRelativePaths.Contains(x.Replace(".diff", ".bsdiff")))
                    .ForEach(file => {
                        pathsVisited.Add(Regex.Replace(file, @"\.(bs)?diff$", "").ToLowerInvariant());
                        applyDiffToFile(deltaPath, file, workingPath);
                    });

                // Delete all of the files that were in the old package but
                // not in the new one.
                new DirectoryInfo(workingPath).GetAllFilesRecursively()
                    .Select(x => x.FullName.Replace(workingPath + Path.DirectorySeparatorChar, "").ToLowerInvariant())
                    .Where(x => x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase) && !pathsVisited.Contains(x))
                    .ForEach(x => {
                        this.Log().Info("{0} was in old package but not in new one, deleting", x);
                        File.Delete(Path.Combine(workingPath, x));
                    });

                // Update all the files that aren't in 'lib' with the delta
                // package's versions (i.e. the nuspec file, etc etc).
                deltaPathRelativePaths
                    .Where(x => !x.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase))
                    .ForEach(x => {
                        this.Log().Info("Updating metadata file: {0}", x);
                        File.Copy(Path.Combine(deltaPath, x), Path.Combine(workingPath, x), true);
                    });

                this.Log().Info("Repacking into full package: {0}", outputFile);
                fz.CreateZip(outputFile, workingPath, true, null);
            }

            return new ReleasePackage(outputFile);
        }
开发者ID:RxSmart,项目名称:Squirrel.Windows,代码行数:56,代码来源:DeltaPackage.cs

示例5: Clean


//.........这里部分代码省略.........
                    "wp",
                    "wp7",
                    "wp75",
                    "wp8",
                    "wp81",
                    "wpa81",
                    // Universal Windows Platform
                    "uap",
                    "uap10",
                    // .NET Standard
                    // See here: https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/
                    "netstandard",
                    "netstandard1.0",
                    "netstandard1.1",
                    "netstandard1.2",
                    "netstandard1.3",
                    "netstandard1.4",
                    "netstandard1.5",
                    "netstandard1.6",
                    // .NET Core App
                    "netcoreapp",
                    "netcoreapp1.0",
                    "cf", // compact framework
                    "monoandroid",
                    "monotouch",
                    "xamarin.ios10",
                    "xamarin.mac20"
                };

                string[] libDirectories = Directory.GetDirectories(packageInstallDirectory + "/lib");
                foreach (var directory in libDirectories)
                {
                    string directoryName = new DirectoryInfo(directory).Name.ToLower();
                    if (directoriesToDelete.Any(directoryName.Contains))
                    {
                        LogVerbose("Deleting unused directory: {0}", directory);
                        DeleteDirectory(directory);
                    }
                    else if (directoryName.Contains("net20") && (has30 || has35))
                    {
                        // if .NET 2.0 exists, keep it, unless there is also a .NET 3.0 or 3.5 version as well
                        LogVerbose("Deleting net20: {0}", directory);
                        DeleteDirectory(directory);
                    }
                    else if (directoryName.Contains("net30") && has35)
                    {
                        // if .NET 3.0 exists, keep it, unless there is also a .NET 3.5 version as well
                        LogVerbose("Deleting net30: {0}", directory);
                        DeleteDirectory(directory);
                    }
                }
            }

            if (Directory.Exists(packageInstallDirectory + "/tools"))
            {
                // Delete all JavaScript in the tools directory since Unity will think it's "UnityScript"
                DeleteAllFiles(packageInstallDirectory + "/tools", "*.js");

                // Delete all DLLs in the tools directory since we can't tell which .NET version they target
                DeleteAllFiles(packageInstallDirectory + "/tools", "*.dll");
            }

            // delete all PDB files since Unity uses Mono and requires MDB files, which causes it to output "missing MDB" errors
            DeleteAllFiles(packageInstallDirectory, "*.pdb");

            // if there are native DLLs, copy them to the Unity project root (1 up from Assets)
开发者ID:GlitchEnzo,项目名称:NuGetForUnity,代码行数:67,代码来源:NugetHelper.cs


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