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


C# DirectoryInfo.Replace方法代码示例

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


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

示例1: CreateProject

    public static Project CreateProject(string filename, string projectName, string buildDirectory)
    {
        //create the build directory
        if (!Directory.Exists(buildDirectory)) {
            Directory.CreateDirectory(buildDirectory);
        }

        //make the build directory relative to project file
        buildDirectory = new DirectoryInfo(buildDirectory).FullName;
        buildDirectory = buildDirectory.Replace(
                new FileInfo(filename).Directory.FullName + "\\",
                "");

        //create the initial template for a Project
        File.WriteAllBytes(filename, new byte[256 + 2]);
        Project buffer = new Project(filename);

        //create the root directory
        buffer.p_NextEntityID = 1;
        buffer.p_ProjectName = projectName;
        buffer.p_BuildDirectory = buildDirectory;
        buffer.p_Directories = new ProjectDirectory[] {
            new ProjectDirectory("{root}", buffer)
        };

        //cause a save so the Project can do all
        //the creating for us
        buffer.Save();
        return buffer;
    }
开发者ID:TomWilsonCoder,项目名称:oside,代码行数:30,代码来源:Project.cs

示例2: CreateFolder

        /// <summary>
        /// Create Folder on Google Drive
        /// </summary>
        /// <param name="FolderName"></param>
        /// <param name="parentID"></param>
        private string CreateFolder(string FolderName, string parentID)
        {
            try
            {
                string KatalogName = new DirectoryInfo(FolderName).Name.Trim('\\');

                IList<Moss> _Files = new List<Moss>();
                Moss _filesID = new Moss();

                if (parentID == "root")
                {
                    _Files = GoogleDrive.GetFilesMoss(service, "'root' in parents and name = '" + KatalogName.Replace(@"\", "") + "' and mimeType = 'application/vnd.google-apps.folder' and trashed = false", false, null);
                    if (_Files.Count == 0)
                    {
                        _filesID = (GoogleDrive.createDirectory(service, KatalogName.Replace(@"\", ""), null, parentID));

                        if (_completeFolderList)
                            googleDriveFolderListMoss.Add(_filesID);
                        else
                        {
                            lock (googleDriveFolderListMoss_Temp)
                            {
                                googleDriveFolderListMoss_Temp.Add(_filesID);
                            }
                        }
                    }
                    else if (_Files.Count > 1)
                    {
                        MessageBox.Show("Fatal error. You have more than one 'Backup in Cloud' folder on your Google Drive");
                        return null;
                    }
                    else if (_Files.Count == 1)
                    {
                        lb_listProgress("Folder: [" + KatalogName + "] exist");
                        _filesID = _Files[0];
                    }

                    return _filesID.Id;
                }
                else
                {
                    _Files = findFolder(KatalogName.Replace(@"\", ""), parentID, null);
                    if (_Files.Count == 0)
                    {
                        _filesID = (GoogleDrive.createDirectory(service, KatalogName.Replace(@"\", ""), null, parentID));

                        if (_completeFolderList)
                            googleDriveFolderListMoss.Add(_filesID);
                        else
                            lock (googleDriveFolderListMoss_Temp)
                            {
                                googleDriveFolderListMoss_Temp.Add(_filesID);
                            }
                    }
                    else
                    {
                        lb_listProgress("Folder: [" + KatalogName + "] exist");
                        _filesID = _Files[0];
                    }
                    return _filesID.Id;
                }
            }
            catch (Exception x) { log.Error("Exception[12]: " + FolderName + " |" + x.Message + " | " + x); return null; }
        }
开发者ID:m4rcelpl,项目名称:Backup-in-Cloud,代码行数:69,代码来源:MainWindow.xaml.cs

示例3: CreateSolution

    public static Solution CreateSolution(string filename, string name, string buildDirectory)
    {
        //valid name?
        if (!Helpers.ValidFilename(name)) {
            throw new Exception("Invalid solution name \"" + name + "\"");
        }

        //create the build directory
        if (!Directory.Exists(buildDirectory)) {
            Directory.CreateDirectory(buildDirectory);
        }

        //get the relative path of the build directory
        buildDirectory = new DirectoryInfo(buildDirectory).FullName;
        buildDirectory = buildDirectory.Replace(
            new FileInfo(filename).Directory.FullName + "\\",
            "");

        //create the output stream
        FileStream fs = new FileStream(filename, FileMode.Create);

        //write the solution name and build directory
        Helpers.WriteString255(name, fs);
        writePath(buildDirectory, fs);

        fs.Close();
        return new Solution(filename);
    }
开发者ID:TomWilsonCoder,项目名称:oside,代码行数:28,代码来源:Solution.cs


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