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


C# System.Collections.Specialized.StringCollection.CopyTo方法代码示例

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


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

示例1: TestDirProcMain

        public TestDirProcMain()
        {
            InitializeComponent();
            _EventLog = new Logging();
            _EventLog.logFileName = "EventLog";
            _EventLog.WriteToLog("EventLog has been created.");

            _validExtList =  Properties.Settings.Default.ValidFileExt.Split(',').ToList<string>();
            System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();
            sc = Properties.Settings.Default.ScanDirectories;
            if (sc.Count > 0)
            {
                _scanDirs = new string[sc.Count];
                sc.CopyTo(_scanDirs, 0);
            }
            else
            {
                _scanDirs = new string[1];
                _scanDirs[0] = Properties.Settings.Default.ScanDirectory;
            }
            
            tbRootDir.Text = initTestDirectory(_scanDirs[0], "Scan");
            tbOuputDir.Text = initTestDirectory(Properties.Settings.Default.OutputDirectory,"Output");
            tbFailedDir.Text = initTestDirectory(Properties.Settings.Default.FailedDirectory,"Failed");;
            tbProcessedDir.Text = initTestDirectory(Properties.Settings.Default.ProcessedDirectory, "Processed"); ;
            tbFileName.Text = Properties.Settings.Default.TestFileName;
           
        }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:28,代码来源:TestDirProcMain.cs

示例2: ServiceMain

        public ServiceMain()
        {
            InitializeComponent();
            _logFile = new Logging();
            _logFile.logFileName = "EventLog";
            _logFile.WriteToLog("EventLog has been created.");

            string minuteDisplay;
            int timerIntervalMinutes = Properties.Settings.Default.TimerIntervalMinutes;
            minuteDisplay = timerIntervalMinutes == 1 ? " minute." : " minutes.";

            _timerIntervalMilliseconds = 1000 * 60 * timerIntervalMinutes;
            _logFile.WriteToLog("Timer interval set to " + timerIntervalMinutes.ToString() + minuteDisplay);

            System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();
            sc = Properties.Settings.Default.ScanDirectories;
            string[] scanDir = new string[sc.Count];

            //Copies all rows from string collection
            sc.CopyTo(scanDir, 0);

            string dirDisplay;
            dirDisplay = sc.Count == 1 ? "directory" : "directories";
            _logFile.WriteToLog("The following source " + dirDisplay + " will be scanned:");
            foreach (string dirName in scanDir)
            {
                _logFile.WriteToLog("--> " + dirName);
            }

            //jvc
            string failedDir = Properties.Settings.Default.FailedDirectory;
            _logFile.WriteToLog("FailedDirectory=" + failedDir);

            string outputDir = Properties.Settings.Default.OutputDirectory;
            string processedDir = Properties.Settings.Default.ProcessedDirectory;
            string validFileExt = Properties.Settings.Default.ValidFileExt;
            bool isDebugLogEnabled = Properties.Settings.Default.DebugLogEnabled;

            //_logFile.WriteToLog("OutputDirectory=" + outputDir);
            _logFile.WriteToLog("ProcessedDirectory=" + processedDir);
            _logFile.WriteToLog("ValidFileExt=" + validFileExt);
            _logFile.WriteToLog("DebugLogEnabled=" + isDebugLogEnabled);

            _logFile.WriteToLog("Creating DirectoryPoller...");
            _dirProcessor = new DirectoryProcessor(scanDir, validFileExt, outputDir, processedDir, failedDir, _logFile);
            _dirProcessor._isDebugLogEnabled = isDebugLogEnabled;
            _dirProcessor._EventLog = _logFile;
            _logFile.WriteToLog("DirectoryPoller was successfully created.");

            this.timerMain.Interval = _timerIntervalMilliseconds;
            //this.timerMain.Elapsed += new System.Timers.ElapsedEventHandler(timerMain_Elapsed);

            // If the timer is declared in a long-running method, use
            // KeepAlive to prevent garbage collection from occurring
            // before the method ends.
            GC.KeepAlive(timerMain);
        }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:57,代码来源:ServiceMain.cs

示例3: DeleteFiles

        private void DeleteFiles()
        {
            System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
            IEnumerable<IBrowserItem> itemset = Browser.CurSelItems;

            foreach (IBrowserItem item in itemset)
            {
                files.Add(item.FullPath);
            }

            ShellLib.ShellFileOperation fo = new ShellLib.ShellFileOperation();

            string[] filearray = new string[files.Count];
            files.CopyTo(filearray, 0);
            fo.Operation = ShellLib.ShellFileOperation.FileOperations.FO_DELETE;
            fo.OwnerWindow = Program.form.Handle;
            fo.SourceFiles = filearray;

            fo.OperationFlags = ShellLib.ShellFileOperation.ShellFileOperationFlags.FOF_NO_CONNECTED_ELEMENTS
                | ShellLib.ShellFileOperation.ShellFileOperationFlags.FOF_WANTNUKEWARNING;

            bool retVal = fo.DoOperation();

            Browser.Refresh();

            if (retVal == false)
            {
                throw new Exception("Shell File Operation Failed");
            }
        }
开发者ID:blmarket,项目名称:filehatchery,代码行数:30,代码来源:BaseEngine.cs

示例4: RelativePathTo

        /// <summary>
        ///   Creates a relative path from one file or folder to another.
        /// </summary>
        /// <param name = "fromDirectory">
        ///   Contains the directory that defines the 
        ///   start of the relative path.
        /// </param>
        /// <param name = "toPath">
        ///   Contains the path that defines the
        ///   endpoint of the relative path.
        /// </param>
        /// <returns>
        ///   The relative path from the start
        ///   directory to the end path.
        /// </returns>
        /// <exception cref = "ArgumentNullException"></exception>
        public static string RelativePathTo(string fromDirectory, string toPath)
        {
            if (fromDirectory == null)
            throw new ArgumentNullException("fromDirectory");

              if (toPath == null)
            throw new ArgumentNullException("toPath");

              bool isRooted = Path.IsPathRooted(fromDirectory) && Path.IsPathRooted(toPath);

              if (isRooted)
              {
            bool isDifferentRoot = String.Compare(Path.GetPathRoot(fromDirectory), Path.GetPathRoot(toPath), true) != 0;

            if (isDifferentRoot)
              return toPath;
              }

              StringCollection relativePath = new StringCollection();
              string[] fromDirectories = fromDirectory.Split(Path.DirectorySeparatorChar);

              string[] toDirectories = toPath.Split(Path.DirectorySeparatorChar);

              int length = Math.Min(fromDirectories.Length, toDirectories.Length);

              int lastCommonRoot = -1;

              // find common root
              for (int x = 0; x < length; x++)
              {
            if (String.Compare(fromDirectories[x], toDirectories[x], true) != 0)
              break;

            lastCommonRoot = x;
              }

              if (lastCommonRoot == -1)
            return toPath;

              // add relative folders in from path
              for (int x = lastCommonRoot + 1; x < fromDirectories.Length; x++)
            if (fromDirectories[x].Length > 0)
              relativePath.Add("..");

              // add to folders to path
              for (int x = lastCommonRoot + 1; x < toDirectories.Length; x++)
            relativePath.Add(toDirectories[x]);

              // create relative path
              string[] relativeParts = new string[relativePath.Count];
              relativePath.CopyTo(relativeParts, 0);

              string newPath = String.Join(Path.DirectorySeparatorChar.ToString(), relativeParts);

              return newPath;
        }
开发者ID:Erls-Corporation,项目名称:MPTagThat,代码行数:72,代码来源:Util.cs

示例5: loadAddIns

        /// <summary>
        /// Load the addins to the FrontEnd
        /// </summary>
        /// <param name="ownerOfAddIn">Who will own this addin</param>
        /// <param name="objectAdapter">Some ice stuff</param>
        /// <param name="modulesManager">Modules Manager</param>
        /// <param name="displayer">Displayer of the properties (if an Add-in has a property)</param>
        private static void loadAddIns(IOwnerOfAddIn ownerOfAddIn,
            Ice.ObjectAdapter objectAdapter,
            Ferda.ModulesManager.ModulesManager modulesManager, Properties.IOtherObjectDisplayer displayer)
        {
            System.Collections.Specialized.StringCollection proxies
                = new System.Collections.Specialized.StringCollection();

            foreach(string file in System.IO.Directory.GetFiles("AddIns"))
            {
                if(System.IO.Path.GetExtension(file) == ".dll")
                {
                    string path = "Ferda.FrontEnd.AddIns." +
                        System.IO.Path.GetFileNameWithoutExtension(file) +
                        ".Main";

                    //tohle se nezvladne
                    Assembly asembly =
                        System.Reflection.Assembly.LoadFile(System.IO.Path.GetFullPath(file));

                    IAddInMain addInMain = (IAddInMain)asembly.CreateInstance(path);

                    //adding the properties displayer if it is a addin capable of
                    //displaying properties
                    if (addInMain is Properties.IPropertyProvider)
                    {
                        Properties.IPropertyProvider prov = addInMain as
                            Properties.IPropertyProvider;

                        prov.Displayer = displayer;
                    }

                    addInMain.OwnerOfAddIn = ownerOfAddIn;
                    addInMain.ObjectAdapter = objectAdapter;
                    proxies.AddRange(addInMain.ObjectProxiesToAdd);
                    addIns.Add(addInMain);
                }
            }
            int count = proxies.Count;
            string[] newServices = new string[count];
            if(count > 0)
            {
                proxies.CopyTo(newServices, 0);
            }
            modulesManager.AddModuleServices(newServices);
        }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:52,代码来源:FerdaForm.cs

示例6: CLAutoThumbnailer

        /// <summary>
        /// Prevents a default instance of the <see cref="CLAutoThumbnailer"/> class from being created.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        /// <param name="baseDir">If created via command file the directory of the command file,
        /// otherwise <c>null</c>.</param>
        /// <exception cref="NDesk.Options.OptionException">Thrown when option error occurs.</exception>
        CLAutoThumbnailer(string[] args, string baseDir)
        {
            InitializeThumbnailSettings ();
            InitializeVideoRE ();

            System.Collections.Specialized.StringCollection fixedArgs =
                new System.Collections.Specialized.StringCollection ();
            foreach (string arg in args)
                {
                if (arg.EndsWith("\""))
                    {
                    fixedArgs.Add(arg.Remove(arg.Length-1));
                    }
                else
                    fixedArgs.Add(arg);
                }

            String[] fixedArgsArray = new String[fixedArgs.Count];
            fixedArgs.CopyTo(fixedArgsArray, 0);
            double doubleInterval = -1;

            _oset = new NDesk.Options.OptionSet () {
                { "d|directory=",
                  "{DIRECTORY} to process. Generate thumbnails for\n" +
                   "files with the following extensions:\n" +
                   _videoExtensions,
                  v => _directoryArg = v },
                { "exts=",
                  "add/remove video {EXTENSIONS} " +
                  "(\"[+]ext1, -ext2\")",
                    v =>
                    {
                    string[] exts = _commaRE.Split(v);
                    foreach (string ext in exts)
                        {
                        string s = ext.Trim().ToLower();
                        bool addExt = true;
                        if (s[0] == '-')
                            {
                            s = s.Substring(1);
                            addExt = false;
                            }
                        else if (s[0] == '+')
                            {
                            s = s.Substring (1);
                            }
                        if (addExt)
                            {
                            if (_videoExts.Contains (s))
                                THelper.Error ("Error: '{0}' is already in valid video extensions list.", s);
                            else
                                {
                                THelper.Information ("'{0}' added to valid video extensions list.", s);
                                _videoExts.Add (s);
                                _videoExtsChanged = true;
                                }
                            }
                        else
                            {
                            if (!_videoExts.Contains (s))
                                THelper.Error ("Error: '{0}' isn't in valid video extensions list.", s);
                            else
                                {
                                THelper.Information ("'{0}' removed from valid video extensions list.", s);
                                _videoExts.Remove (s);
                                _videoExtsChanged = true;
                                }
                            }
                        }
                    if (_videoExtsChanged)
                        {
                        System.Collections.ArrayList temp = System.Collections.ArrayList.Adapter(_videoExts);
                        temp.Sort ();
                        _videoExts = new System.Collections.Specialized.StringCollection ();
                        _videoExts.AddRange ((String[]) temp.ToArray(typeof(string)));
                        }
                    } },

                { "minsize=",
                   String.Format("Minimum {{FILESIZE}} of video files (0 to disable) [{0} ({1})]",
                                  _minFileSize, ThumbnailCreator.GetFileSizeString(_minFileSize)),
                    (long v) =>
                        {
                        if (v < 0)
                            v = 0;
                        _minFileSize = v;
                        } },

                { "m|cmddir=",
                   "create initial command file for {DIRECTORY}",
                   v => _cmdDirectory = v },

                { "s|start=",
//.........这里部分代码省略.........
开发者ID:rm2,项目名称:CLAutoThumbnailer,代码行数:101,代码来源:CLAutoThumbnailer.cs

示例7: GetArgs

        static string[] GetArgs(string s)
        {
            System.Collections.Specialized.StringCollection scArgs =
                new System.Collections.Specialized.StringCollection ();
            StringBuilder arg = new StringBuilder ();

            bool seenQuote = false;
            foreach (char c in s)
                {
                if (char.IsWhiteSpace (c))
                    {
                    if (seenQuote)
                        arg.Append (c);
                    else
                        {
                        if (arg.Length > 0)
                            scArgs.Add (arg.ToString ());
                        arg.Clear ();
                        }
                    }
                else
                    {
                    if (c == '"')
                        {
                        seenQuote = !seenQuote;
                        }
                    else
                        {
                        arg.Append (c);
                        }
                    }
                }

            if (arg.Length > 0)
                scArgs.Add (arg.ToString ());

            String[] args = new String[scArgs.Count];
            scArgs.CopyTo (args, 0);

            return args;
        }
开发者ID:rm2,项目名称:CLAutoThumbnailer,代码行数:41,代码来源:CLAutoThumbnailer.cs

示例8: DoNickComplete

        private string[] DoNickComplete(string word)
        {
            System.Collections.Specialized.StringCollection sc = new System.Collections.Specialized.StringCollection();

            foreach (ChanUser cu in lstUsers.Items)
            {
                if (cu.Nick.ToLower().StartsWith(word.ToLower()))
                {
                    sc.Add(cu.Nick);
                }
            }

            foreach (TreeNode tn in Obsidian.mainForm.tvcWindows.Nodes)
            {
                if (tn.Text.ToLower().StartsWith(word.ToLower()))
                {
                    sc.Add(tn.Text);
                }

                /* fix: go through channel window nodes, query nodes, etc. */
                foreach (TreeNode tn2 in tn.Nodes)
                {
                    foreach (TreeNode tn3 in tn2.Nodes)
                    {
                        if (tn3.Text.ToLower().StartsWith(word.ToLower()))
                        {
                            sc.Add(tn3.Text);
                        }
                    }
                }
            }

            string[] a = new string[sc.Count];
            sc.CopyTo(a, 0);
            return a;
        }
开发者ID:rburchell,项目名称:obsidian,代码行数:36,代码来源:mcPage.cs

示例9: FormatSingleLineMaxChars

        // Formats a string so that no line will have more than maxLen characters.
        // Input strings may not contain a \r or \n. To format multi-line strings call
        // FormatMultiLineMaxChars
        public static string[] FormatSingleLineMaxChars( int maxLen, string sLine )
        {
            System.Diagnostics.Debug.Assert( maxLen > 0, "Max must be at least 1" );
              System.Diagnostics.Debug.Assert( -1 == sLine.IndexOf( '\r' ) );
              System.Diagnostics.Debug.Assert( -1 == sLine.IndexOf( '\n' ) );

              if(  maxLen <= 0 ) return null;
              if( 0 == sLine.Length ) return new String[]{""};

              int currentStart = 0;
              int currentEnd;
              System.Collections.Specialized.StringCollection txt = new System.Collections.Specialized.StringCollection();

              while(  currentStart < sLine.Length  ) {
            if(  currentStart + maxLen < sLine.Length  ) {
              currentEnd = Math.Min(  currentStart + maxLen,  sLine.Length - 1  );

              int spaceIdx = sLine.LastIndexOf(  " ",  currentEnd,  currentEnd - currentStart  );

              if(  -1 == spaceIdx  ) {
            txt.Add(  sLine.Substring( currentStart, currentEnd - currentStart )  );
            currentStart += maxLen;
              }
              else {
            txt.Add(  sLine.Substring( currentStart, spaceIdx - currentStart )  );
            currentStart = spaceIdx + 1;
              }
            }
            else {
              txt.Add(  sLine.Substring( currentStart )  );
              currentStart += maxLen;
            }
              }

              string[] lines = new string[ txt.Count ];
              txt.CopyTo( lines, 0 );
              return lines;
        }
开发者ID:PatricioVidal,项目名称:GpsMapTools,代码行数:41,代码来源:CommandLineParser.cs

示例10: FormatMultiLineMaxChars

        // Splits a string containing new lines (assumed to be \n or \r\n) and passes each
        // line to FormatSingleLineMaxChars and returns the resulting string array
        public static string[] FormatMultiLineMaxChars( int maxLen, string sLine )
        {
            System.Diagnostics.Debug.Assert( maxLen > 0, "Max must be at least 1" );
              if(  maxLen <= 0 ) return null;

              string[] lines = sLine.Replace( "\r", "" ).Split( new char[]{'\n'} );
              System.Collections.Specialized.StringCollection formattedLines = new System.Collections.Specialized.StringCollection();

              foreach( string line in lines )
            formattedLines.AddRange( FormatSingleLineMaxChars( maxLen, line ) );

              string[] multi = new string[ formattedLines.Count ];
              formattedLines.CopyTo( multi, 0 );
              return multi;
        }
开发者ID:PatricioVidal,项目名称:GpsMapTools,代码行数:17,代码来源:CommandLineParser.cs


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