本文整理汇总了C#中IWorkspaceFileObject.ConvertToFormat方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkspaceFileObject.ConvertToFormat方法的具体用法?C# IWorkspaceFileObject.ConvertToFormat怎么用?C# IWorkspaceFileObject.ConvertToFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkspaceFileObject
的用法示例。
在下文中一共展示了IWorkspaceFileObject.ConvertToFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectValidFileFormat
bool SelectValidFileFormat (IWorkspaceFileObject item)
{
var dlg = new SelectFileFormatDialog (item);
try {
if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok && dlg.Format != null) {
item.ConvertToFormat (dlg.Format, true);
return true;
}
return false;
} finally {
dlg.Destroy ();
}
}
示例2: Export
string Export (IProgressMonitor monitor, IWorkspaceFileObject obj, string[] includedChildIds, string targetPath, FileFormat format)
{
string rootSourceFile = obj.FileName;
string sourcePath = Path.GetFullPath (Path.GetDirectoryName (rootSourceFile));
targetPath = Path.GetFullPath (targetPath);
if (sourcePath != targetPath) {
if (!CopyFiles (monitor, obj, obj.GetItemFiles (true), targetPath, true))
return null;
string newFile = Path.Combine (targetPath, Path.GetFileName (rootSourceFile));
if (IsWorkspaceItemFile (rootSourceFile))
obj = ReadWorkspaceItem (monitor, newFile);
else
obj = (SolutionEntityItem) ReadSolutionItem (monitor, newFile);
using (obj) {
List<FilePath> oldFiles = obj.GetItemFiles (true);
ExcludeEntries (obj, includedChildIds);
if (format != null)
obj.ConvertToFormat (format, true);
obj.Save (monitor);
List<FilePath> newFiles = obj.GetItemFiles (true);
foreach (FilePath f in newFiles) {
if (!f.IsChildPathOf (targetPath)) {
if (obj is Solution)
monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the root solution directory.", null);
else
monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + f.FileName + "' which is located outside the project directory.", null);
}
oldFiles.Remove (f);
}
// Remove old files
foreach (FilePath file in oldFiles) {
if (File.Exists (file)) {
File.Delete (file);
// Exclude empty directories
FilePath dir = file.ParentDirectory;
if (Directory.GetFiles (dir).Length == 0 && Directory.GetDirectories (dir).Length == 0) {
try {
Directory.Delete (dir);
} catch (Exception ex) {
monitor.ReportError (null, ex);
}
}
}
}
return obj.FileName;
}
}
else {
using (obj) {
ExcludeEntries (obj, includedChildIds);
if (format != null)
obj.ConvertToFormat (format, true);
obj.Save (monitor);
return obj.FileName;
}
}
}