本文整理汇总了C#中IFile.ImportFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFile.ImportFile方法的具体用法?C# IFile.ImportFile怎么用?C# IFile.ImportFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFile
的用法示例。
在下文中一共展示了IFile.ImportFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameTo
/// <summary>
/// Renames/Moves this file to the specified file instance.
/// </summary>
/// <param name="dest">File to rename/move to.</param>
/// <returns>boolean true - success, false - failure</returns>
public bool RenameTo(IFile dest)
{
if (dest is LocalFile) {
bool status = true;
// Allready exists
if (dest.Exists)
return false;
// Hmm, invalid rename
string srcPath = this.IsFile ? this.AbsolutePath : this.AbsolutePath + "/";
string destPath = dest.IsFile ? dest.AbsolutePath : dest.AbsolutePath + "/";
if (destPath.IndexOf(srcPath) == 0)
return false;
this.DispatchBeforeFileAction(FileAction.Rename, dest);
if (this.fileInfo != null) {
this.fileInfo.MoveTo(dest.AbsolutePath);
this.fileInfo.Refresh();
} else {
this.dirInfo.MoveTo(dest.AbsolutePath);
this.dirInfo.Refresh();
}
this.DispatchFileAction(FileAction.Rename, dest);
return status;
} else {
dest.ImportFile(this.AbsolutePath);
this.Delete(true);
return true;
}
}
示例2: CopyTo
/// <summary>Copies the file to the destination file.</summary>
/// <param name="dest">Destination file to copy to.</param>
public bool CopyTo(IFile dest)
{
if (dest is LocalFile) {
if (dest.Exists)
return false;
if (dest.AbsolutePath.IndexOf(this.AbsolutePath) == 0)
return false;
this.DispatchBeforeFileAction(FileAction.Copy, dest);
if (this.IsFile)
this.fileInfo.CopyTo(PathUtils.ToOSPath(dest.AbsolutePath));
else
this.CopyDirectory(PathUtils.ToOSPath(this.AbsolutePath), PathUtils.ToOSPath(dest.AbsolutePath));
this.DispatchFileAction(FileAction.Copy, dest);
} else
dest.ImportFile(this.AbsolutePath);
return true;
}