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


C# IComponent.AddComponent方法代码示例

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


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

示例1: loadComposites

        private void loadComposites(string path, IComponent root)
        {
            try
            {
                string[] files = Directory.GetFiles(path, ".");
            }
            catch
            {
                Console.WriteLine("Folder doesn't exist!");
                return;
            }

            try
            {
                string[] folders = Directory.GetDirectories(path);
                foreach (string folderPath in folders)
                {
                    this.id++;
                    dir folder = null;

                    folder = new dir { path = folderPath, id = this.id, name = new DirectoryInfo(folderPath).Name, folder = true, root = root, link = System.IO.File.GetAttributes(folderPath).HasFlag(FileAttributes.ReparsePoint) };

                    root.AddComponent(folder);
                    loadComposites(folderPath, folder);
                }
                loadLeafs(path, root);
                root.CalculateSize();
            }
            catch
            {
                Console.WriteLine("Error");
            }
        }
开发者ID:tdukaric,项目名称:Design-Patterns,代码行数:33,代码来源:NTFS.cs

示例2: loadLeafs

        private void loadLeafs(string path, IComponent root)
        {

            string[] files = Directory.GetFiles(path);

            foreach (string file in files)
            {
                this.id++;
                FileInfo fileInfo = new FileInfo(file);

                file dat = new file { path = file, name = fileInfo.Name, size = fileInfo.Length, id = this.id, folder = false, root = root, permitWriting = !fileInfo.IsReadOnly, link = System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint) };
                root.AddComponent(dat);
            }
        }
开发者ID:tdukaric,项目名称:Design-Patterns,代码行数:14,代码来源:NTFS.cs

示例3: loadLeafs

        private void loadLeafs(string path, IComponent root)
        {

            string[] folders = Directory.GetFiles(path);

            foreach (string file in folders)
            {
                this.id++;
                FileInfo temp = new FileInfo(file);
                file dat;
                if (System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint))
                {
                    continue;
                }
                else
                {
                    dat = new file { path = file, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = root, permitWriting = !temp.IsReadOnly };
                }
                root.AddComponent(dat);
            }
        }
开发者ID:tdukaric,项目名称:Design-Patterns,代码行数:21,代码来源:exFAT.cs

示例4: copyFolder

        private void copyFolder(string what, string where, IComponent root)
        {

            DirectoryInfo dir = new DirectoryInfo(what);
            DirectoryInfo[] dirs = dir.GetDirectories();

            DirectoryInfo _dir = Directory.CreateDirectory(where);

            this.id++;
            dir folder = null;
            if (DS_Type == "NTFS")
            {
                folder = new dir { path = _dir.FullName, id = this.id, name = _dir.Name, folder = true, root = root, link = System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint) };
            }
            else if (DS_Type == "exFAT")
            {
                if (!System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint))
                    folder = new dir { path = _dir.FullName, id = this.id, name = new DirectoryInfo(_dir.FullName).Name, folder = true, root = root, link = false };
            }

            root.AddComponent(folder);

            foreach (DirectoryInfo subdir in dirs)
            {
                string temppath = Path.Combine(where, subdir.Name);
                copyFolder(subdir.FullName, temppath, folder);
            }
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                this.id++;
                string temppath = Path.Combine(where, file.Name);
                FileInfo temp = file.CopyTo(temppath, false);

                file dat = new file { path = temp.FullName, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = folder, permitWriting = !temp.IsReadOnly, link = System.IO.File.GetAttributes(temp.FullName).HasFlag(FileAttributes.ReparsePoint) };
                folder.AddComponent(dat);

            }
        }
开发者ID:tdukaric,项目名称:Design-Patterns,代码行数:39,代码来源:exFAT.cs


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