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


C# Project.ToAbsoluteFileName方法代码示例

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


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

示例1: RenameFile

			public static bool RenameFile(Project Project, string file, string NewFileName)
			{
				var absPath = Project.ToAbsoluteFileName(file);
				var newFilePath =Path.Combine(Project.BaseDirectory, Path.GetDirectoryName(NewFileName),Util.PurifyFileName(Path.GetFileName(NewFileName)));
				var ret = Util.MoveFile(absPath, newFilePath);
				if (ret)
				{
					Project.Remove(file);
					Project.Add(newFilePath);
					Project.Save();

					foreach (var e in Instance.Editors)
						if (e.AbsoluteFilePath == absPath)
						{
							e.AbsoluteFilePath = newFilePath;
							e.Reload();
						}
				}
				return ret;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:20,代码来源:FileManagement.cs

示例2: ExludeFileFromProject

			public static bool ExludeFileFromProject(Project Project, string file)
			{
				var absFile = Project.ToAbsoluteFileName(file);
				// Close (all) editor(s) that represent our file
				foreach (var ed in Instance.Editors.Where(e => e.AbsoluteFilePath == absFile).ToArray())
					if (!ed.Close())
						return false;

				var r = Project.Remove(file);
				if (r)
				{
					Project.Save();
					Instance.MainWindow.RefreshProjectExplorer();
				}
				return r;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:16,代码来源:FileManagement.cs

示例3: RemoveFileFromProject

			public static bool RemoveFileFromProject(Project Project, string file)
			{
				var r = ExludeFileFromProject(Project, file);
				try
				{
					if (r) Win32.MoveToRecycleBin(Project.ToAbsoluteFileName(file));
				}
				catch { }
				return r;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:10,代码来源:FileManagement.cs

示例4: ExcludeDirectoryFromProject

			public static bool ExcludeDirectoryFromProject(Project prj, string RelativePath)
			{
				if (prj == null || string.IsNullOrEmpty(RelativePath))
					return false;

				/*
				 * - Delete all subdirectory references
				 * - Delete all files that are inside of these directories
				 */
				var affectedFiles = (from f in prj.Files
									 where Path.GetDirectoryName(f.FileName).Contains(RelativePath)
									 select prj.ToAbsoluteFileName(f.FileName)).ToArray();

				foreach (var ed in Instance.Editors.Where(e => affectedFiles.Contains(e.AbsoluteFilePath)))
					ed.Close();

				foreach (var s in prj.SubDirectories.Where(d => d == RelativePath || d.Contains(RelativePath)).ToArray())
					prj.SubDirectories.Remove(s);

				foreach (var s in affectedFiles)
					prj.Remove(s);

				prj.Save();

				Instance.UpdateGUI();
				return true;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:27,代码来源:FileManagement.cs

示例5: MoveFile

			public static bool MoveFile(Project Project, string FileName, Project TargetProject, string NewDirectory)
			{
				/*
				 * - Copy file
				 * - Delete old physically
				 * - Delete old one from project
				 */
				Instance.CanUpdateGUI = false;
				if (CopyFile(Project, FileName, TargetProject, NewDirectory) && 
					Project.Remove(FileName))
				{
					var oldDir_rel = Path.GetDirectoryName(Project.ToRelativeFileName(FileName));

					foreach(var ed in IDEManager.Instance.Editors)
						if (ed.AbsoluteFilePath == Project.ToAbsoluteFileName(FileName))
						{
							ed.FileName = TargetProject.ToAbsoluteFileName(Path.Combine(NewDirectory, Path.GetFileName(FileName)));
						}

					try
					{
						File.Delete(Project.ToAbsoluteFileName(FileName));
					}
					catch (Exception ex)
					{
						IDELogger.Log(ex);
					}
					// If directory empty, keep it managed by the project
					if (!Project.SubDirectories.Contains(oldDir_rel) && !string.IsNullOrEmpty(oldDir_rel))
						Project.SubDirectories.Add(oldDir_rel);
					Project.Save();
				}
				Instance.CanUpdateGUI = true;
				Instance.UpdateGUI();
				return false;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:36,代码来源:FileManagement.cs

示例6: CopyFile

			public static bool CopyFile(Project Project, string FileName, Project TargetProject, string NewDirectory)
			{
				var tarprj = (Project == TargetProject || TargetProject == null) ? Project : TargetProject;
				/*
				 * - Build file paths
				 * - Try to copy file; if succesful:
				 * - Add to new project
				 * - Save target project
				 */
				var oldFile = Project.ToAbsoluteFileName(FileName);
				var newFile_rel = (NewDirectory + "\\" + Path.GetFileName(FileName)).Trim('\\');
				var newFile_abs = tarprj.ToAbsoluteFileName(newFile_rel);

				if (File.Exists(newFile_abs) || tarprj.ContainsFile(newFile_abs))
					return false;

				try
				{
					File.Copy(oldFile, newFile_abs);
				}
				catch (Exception ex) { ErrorLogger.Log(ex); return false; }

				// Normally this should always return true since we've tested its non-existence before!
				tarprj.Add(newFile_abs);
				tarprj.Save();
				Instance.UpdateGUI();
				return true;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:28,代码来源:FileManagement.cs

示例7: AddExistingDirectoryToProject

			public static bool AddExistingDirectoryToProject(string DirectoryPath, Project Project, string RelativeDir)
			{
				/*
				 * - If dir not controlled by prj, add it
				 * - Copy the directory and all its children
				 * - Save project
				 */
				var newDir_rel = Path.Combine(RelativeDir, Path.GetFileName(DirectoryPath));
				var newDir_abs = Project.ToAbsoluteFileName(newDir_rel);

				// If project dir is a subdirectory of DirectoryPath, return false
				if (Project.BaseDirectory.Contains(DirectoryPath) || DirectoryPath == Project.BaseDirectory)
				{
					MessageBox.Show("Project's base directory is part of " + DirectoryPath + " - cannot add it","File addition error");
					return false;
				}

				if (!Project.SubDirectories.Contains(newDir_rel))
					Project.SubDirectories.Add(newDir_rel);

				Util.CreateDirectoryRecursively(newDir_abs);

				foreach (var file in Directory.GetFiles(DirectoryPath, "*", SearchOption.AllDirectories))
				{
					// Note: Empty directories will be ignored.
					var newFile_rel = file.Substring(DirectoryPath.Length).Trim('\\');
					var newFile_abs = newDir_abs + "\\" + newFile_rel;

					if (Project.Add(newFile_abs)!=null)
					{
						try
						{
							if (file != newFile_abs)
								File.Copy(file, newFile_abs, true);
						}
						catch (Exception ex) { 
							ErrorLogger.Log(ex);
							if(MessageBox.Show("Stop adding files?","Error while adding files",MessageBoxButton.YesNo)==MessageBoxResult.Yes)
								return false; 
						}
					}
				}
				Project.Save();
				Instance.UpdateGUI();
				return true;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:46,代码来源:FileManagement.cs

示例8: Rename

			public static bool Rename(Project prj, string NewName)
			{
				// Prevent moving the project into an other directory
				if (String.IsNullOrEmpty(NewName) || NewName.Contains('\\'))
					return false;

				/*
				 * - Try to rename the project file
				 * - If successful, remove old project file from solution
				 * - Rename the project and it's filename
				 * - Add the 'new' project to the solution
				 * - Save everything
				 */

				var newPrjFileName = Util.PurifyFileName(NewName) + Path.GetExtension(prj.FileName);
				var newAbsPrjFileName = prj.ToAbsoluteFileName(newPrjFileName);
				var ret = Util.MoveFile(prj.FileName, newPrjFileName);
				if (ret)
				{
					var isStartProject = prj.Solution.StartProject == prj;

					prj.Solution.ExcludeProject(prj.FileName);
					prj.Name = NewName;
					prj.FileName = newAbsPrjFileName;
					prj.Solution.AddProject(prj);

					if (isStartProject)
						prj.Solution.StartProject = prj;

					prj.Solution.Save();
					prj.Save();
				}
				return ret;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:34,代码来源:ProjectManagement.cs


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