本文整理汇总了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;
}
示例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; }
}
示例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);
}