當前位置: 首頁>>代碼示例>>C#>>正文


C# DirectoryInfo.RemoveReadOnly方法代碼示例

本文整理匯總了C#中System.IO.DirectoryInfo.RemoveReadOnly方法的典型用法代碼示例。如果您正苦於以下問題:C# DirectoryInfo.RemoveReadOnly方法的具體用法?C# DirectoryInfo.RemoveReadOnly怎麽用?C# DirectoryInfo.RemoveReadOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了DirectoryInfo.RemoveReadOnly方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: CleanDirectories

        private void CleanDirectories(MusicFolderHelper imfh)
        {
            DirectoryInfo di = new DirectoryInfo(imfh.Cache);
            di.RemoveReadOnly();
            di.Empty(true);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            DirectoryInfo diroot = new DirectoryInfo(imfh.Root);
            diroot.RemoveReadOnly();
            diroot.Empty(true);
        }
開發者ID:David-Desmaisons,項目名稱:MusicCollection,代碼行數:13,代碼來源:Preparator.cs

示例3: 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

示例4: CleanDirectories

        protected void CleanDirectories(bool tot = true)
        {
            DirectoryInfo di = new DirectoryInfo(Cache);
            di.RemoveReadOnly();
            di.Empty(true);

           

            GC.Collect();
            GC.WaitForPendingFinalizers();

            if (tot)
            {
                DirectoryInfo diroot = new DirectoryInfo(Root);
                diroot.RemoveReadOnly();
                diroot.Empty(true);
                //Directory.Delete(Root, true);

                //while (diroot.Exists)
                //{
                //    System.Threading.Thread.Sleep(200);
                //    di.Refresh();
                //}
            }
        }
開發者ID:David-Desmaisons,項目名稱:MusicCollection,代碼行數:25,代碼來源:IntegratedBase.cs

示例5: 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.RemoveReadOnly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。