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


C# DirectoryInfo.Copy方法代码示例

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


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

示例1: GlobalSetUp

        //[SetUp]
        public void GlobalSetUp()
        {
            if (_EnvironmentInitialised == false)
            {

                DirectoryInfo difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
                if (difo.Exists)
                {
                    difo.RemoveReadOnly();
                    difo.Empty(true);
                }

                difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                if (difo.Exists)
                {
                    difo.RemoveReadOnly();
                    difo.Empty(true);
                }

                DirectoryInfo dif = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"));
                dif.Copy(Path.GetFullPath(@"..\..\TestFolders\InFolder"));

                difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
                difo.RemoveReadOnly();

                _MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                CleanDirectories(_MFH);

                _MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
                _EnvironmentInitialised = true;
            }
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:33,代码来源:Preparator.cs

示例2: SpawAndRun

 public static bool SpawAndRun( BackupScheduleWrapper job )
 {
     SpawnLogger.Log( "Spawn request {0}".FillBlanks( job.Name ) );
     string procName = "Bummer.ScheduleRunner.{0}".FillBlanks( job.ID );
     Process[] processes = Process.GetProcessesByName( procName );
     if( processes.Length > 0 ) {
         SpawnLogger.Log( "Spawn request, already running {0}".FillBlanks( job.Name ) );
         return false;
     }
     DirectoryInfo dir = new DirectoryInfo( Configuration.DataDirectory.FullName + "\\" + job.ID );
     if( Directory.Exists( dir.FullName ) ) {
         try {
             Directory.Delete( dir.FullName, true );
         } catch( Exception ex ) {
             SpawnLogger.Log( "Spawn request, cleanup failed {0}: {1}".FillBlanks( job.Name, ex.Message ) );
             return false;
         }
     }
     Type t = typeof(ScheduleJobSpawner);
     FileInfo fi = new FileInfo( t.Assembly.Location );
     DirectoryInfo binDir = new DirectoryInfo( fi.DirectoryName );
     binDir.Copy( dir.FullName, true );
     string exeName = "{0}\\{1}.exe".FillBlanks( dir.FullName, procName );
     fi.CopyTo( exeName, true );
     FileInfo[] configs = binDir.GetFiles( "*.config" );
     foreach( FileInfo configFile in configs ) {
         if( configFile.Name.Contains( ".vshost." ) ) {
             continue;
         }
         configFile.CopyTo( exeName + ".config" );
         break;
     }
     SpawnLogger.Log( "Spawn request spawning {0}".FillBlanks( job.Name ) );
     Process p = new Process();
     p.StartInfo = new ProcessStartInfo( exeName );
     p.StartInfo.CreateNoWindow = true;
     p.StartInfo.UseShellExecute = false;
     p.EnableRaisingEvents = true;
     p.Exited += p_Exited;
     p.Start();
     return true;
 }
开发者ID:EsleEnoemos,项目名称:Bummer,代码行数:42,代码来源:Program.cs

示例3: MoveButton_ClickHandler

        public void MoveButton_ClickHandler(object sender, EventArgs e)
        {
            ActionPanel.SetActiveView(FolderContentView);

            var path = RootDir + moveTree.SelectedNode + "\\";
            foreach (string fileName in SelectedFiles)
            {
                File.Move(RootDir + RequestedPath + "\\" + fileName, path + fileName);
            }
            foreach (string directoryName in SelectedDirectories)
            {
                var directory = new DirectoryInfo(RootDir + RequestedPath + "\\" + directoryName);
                directory.Copy(RootDir + RequestedPath + "\\" + directoryName, path + directoryName);
                directory.Delete(true);

            }
            Cache.Remove(RootDir);

            ClearSelectedDirectories();
            ClearSelectedFiles();
        }
开发者ID:AzarinSergey,项目名称:learn,代码行数:21,代码来源:FileManagerControl.ascx.cs

示例4: CopyDirectory

 public static void CopyDirectory(DirectoryInfo src, DirectoryInfo target, bool overwrite = true, bool copySubdirs = true)
 {
     src.Copy(target, overwrite, copySubdirs);
 }
开发者ID:Craftitude-Team,项目名称:Craftitude,代码行数:4,代码来源:FileUtils.cs

示例5: Reinitialize

        protected void Reinitialize()
        {
            CleanDirectories(false);

            DirectoryInfo root = new DirectoryInfo(Root);
            root.RemoveReadOnly();
            root.Empty(true);

            DirectoryInfo In = new DirectoryInfo(DirectoryIn);
            In.RemoveReadOnly();
            In.Empty(true);

            string Pathentry = Path.Combine(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"), this.CopyName);

            DirectoryInfo dif = new DirectoryInfo(Pathentry);
            dif.Copy(DirectoryIn);

            In = new DirectoryInfo(DirectoryIn);
            In.RemoveReadOnly();

            _SK = GetKeys();

            CopyDBIfNeeded();


        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:26,代码来源:IntegratedBase.cs

示例6: Init

        protected void Init()
        {

            _MFH = new MusicFolderHelper(DirectoryOut);
            //_SK = GetKeys();
            DirectoryIn = Path.Combine(RootDirectoryIn, InputDirectorySimpleName);
 
            object[] PIs = this.GetType().GetCustomAttributes(typeof(TestFolderAttribute), false);

            if ((PIs != null) && (PIs.Length > 0))
            {
                TestFolderAttribute tfa = PIs[0] as TestFolderAttribute;
                if (!Directory.Exists(DirectoryIn))
                {
                    Directory.CreateDirectory(DirectoryIn);
                }

                CopyName = tfa.InFolderName ?? InputDirectorySimpleName;
                CopyNameDB = tfa.DBFolderName ?? InputDirectorySimpleName;


                DirectoryInfo dif = new DirectoryInfo(Path.Combine(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"), CopyName));
                dif.Copy(DirectoryIn);


                dif = new DirectoryInfo(DirectoryIn);
                dif.RemoveReadOnly();


                //IsOverride = true;
            }
            else
            {
                CopyName = InputDirectorySimpleName;
                CopyNameDB = InputDirectorySimpleName;
            }

            CopyDBIfNeeded();

            _SK = GetKeys();
            
            OldAlbums = new List<IList<ExportAlbum>>();

            bool continu = true;
            int i = 0;

            while (continu)
            {
                string iPath = Path.Combine(DirectoryIn, string.Format("AlbumRef{0}.xml", i++));
                if (File.Exists(iPath))
                {
                    OldAlbums.Add(ExportAlbums.Import(iPath, false, String.Empty, null));
                }
                else
                    continu = false;
            }


            Albums = new List<IList<AlbumDescriptor>>();

            continu = true;
            i = 0;

            while (continu)
            {
                string iPath = Path.Combine(DirectoryIn, string.Format("Album{0}.xml", i++));
                if (File.Exists(iPath))
                {
                    Albums.Add(AlbumDescriptorExchanger.Import(iPath, false, String.Empty, null));
                }
                else
                    continu = false;
            }

            Albums.SelectMany(o => o).SelectMany(u => u.RawTrackDescriptors.Select(t => new Tuple<AlbumDescriptor, TrackDescriptor>(u, t))).Apply(o => Assert.That(o.Item1, Is.EqualTo(o.Item2.AlbumDescriptor)));

        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:77,代码来源:IntegratedBase.cs


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