Ejemplo n.º 1
0
 public ReadOnlyCollection <string> GetFiles(string directory, Microsoft.VisualBasic.FileIO.SearchOption searchType, params string[] wildcards)
 {
     return(FileSystem.GetFiles(directory, searchType, wildcards));
 }
Ejemplo n.º 2
0
        public static void MyCopyAllFilesInFolder(Task buildTask, string sourceFolder, string targetFolder, string wildCards, bool overWrite, bool onlyReplaceWithNewerFile, bool continueOnError, Microsoft.VisualBasic.FileIO.SearchOption searchOption, bool useRoboCopy, string versionToCopy, string logText)
        {
            var             myComputer = new Computer();
            RobocopyWrapper myWrapper  = null;

            if (useRoboCopy)
            {
                myWrapper   = new RobocopyWrapper();
                useRoboCopy = myWrapper.IsInstalled;
                if (useRoboCopy)
                {
                    if (myWrapper.SupportsMultiThreading)
                    {
                        myWrapper.NumberOfThreads = 8;
                    }
                    else
                    {
                        myWrapper.NumberOfThreads = 1;
                    }
                    switch (searchOption)
                    {
                    case Microsoft.VisualBasic.FileIO.SearchOption.SearchTopLevelOnly:
                        myWrapper.RecursiveMode = RoboCopyRecursiveCopy.CopyTopLevelOnly;
                        break;

                    case Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories:
                        myWrapper.RecursiveMode = RoboCopyRecursiveCopy.CopyAllSubdirectories;
                        break;
                    }
                }
            }
            if (Strings.Len(wildCards) == 0)
            {
                wildCards = "*.*";
            }
            if (Strings.Len(logText) == 0)
            {
                logText = "Copying folder from '{0}' to '{1}'...";
            }
            if (Directory.Exists(sourceFolder))
            {
                MyLogMessage(buildTask, string.Format(logText, sourceFolder, targetFolder), MessageImportance.Normal);
                if (useRoboCopy)
                {
                    MyCopyAllFilesWithRoboCopy(buildTask, myWrapper, sourceFolder, targetFolder, wildCards, onlyReplaceWithNewerFile, continueOnError, versionToCopy);
                }
                else
                {
                    //foreach (string str2 in _MyComputer.FileSystem.GetFiles()
                    foreach (string str2 in myComputer.FileSystem.GetFiles(sourceFolder, searchOption, new string[] { wildCards }))
                    {
                        string targetFile = "";
                        try
                        {
                            string fullPath = Path.GetFullPath(sourceFolder);
                            targetFile = PathHelper.Combine(targetFolder, Strings.Right(str2, (str2.Length - fullPath.Length) - 1));
                            MyCopyFile(buildTask, str2, targetFile, overWrite, onlyReplaceWithNewerFile, "Copying file from '{0}' to '{1}'...", false);
                        }
                        catch (Exception exception1)
                        {
                            ProjectData.SetProjectError(exception1);
                            Exception ex = exception1;
                            if (!continueOnError)
                            {
                                throw;
                            }
                            string exceptionData = GetExceptionData(ex);
                            MyLogWarning(buildTask, string.Format("Error copying file '{0}' to '{1}'. The following error was raised: '{2}'.", str2, targetFile, exceptionData));
                            ProjectData.ClearProjectError();
                        }
                    }
                }
            }
            else
            {
                MyLogMessage(buildTask, string.Format("Source folder '{0}' does not exist and cannot be copied to '{1}'.", sourceFolder, targetFolder), MessageImportance.Normal);
            }
        }
Ejemplo n.º 3
0
 public ReadOnlyCollection <string> FindInFiles(string directory, string containsText, bool ignoreCase, Microsoft.VisualBasic.FileIO.SearchOption searchType, params string[] fileWildcards)
 {
     return(FileSystem.FindInFiles(directory, containsText, ignoreCase, searchType, fileWildcards));
 }
Ejemplo n.º 4
0
 public static void MyCopyAllFilesInFolder(Task buildTask, string sourceFolder, string targetFolder, string wildCards, bool overWrite, bool onlyReplaceWithNewerFile, bool continueOnError, Microsoft.VisualBasic.FileIO.SearchOption searchOption)
 {
     MyCopyAllFilesInFolder(buildTask, sourceFolder, targetFolder, wildCards, overWrite, onlyReplaceWithNewerFile, continueOnError, searchOption, false, string.Empty, string.Empty);
 }