本文整理汇总了C#中IFileSystem.MoveFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.MoveFile方法的具体用法?C# IFileSystem.MoveFile怎么用?C# IFileSystem.MoveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.MoveFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHistory
public static bool CreateHistory(SharedFile file, IFileSystem fileSystem, string virtualFilePath, string virtualHistoryPath)
{
bool historyCreated = false;
//File.Move(Path.Combine(sourceFilePath, Path.GetFileName(this.serverFileName)), Path.Combine(historyFolderPath, Path.GetFileName(this.serverFileName)));
fileSystem.MoveFile(
VirtualPathUtility.Combine(virtualFilePath, file.ServerFileName),
VirtualPathUtility.Combine(virtualHistoryPath, file.ServerFileName),
true);
historyCreated = SharedFile.AddHistory(
file.ItemGuid,
file.ModuleGuid,
file.UserGuid,
file.ItemId,
file.ModuleId,
file.FriendlyName,
file.OriginalFileName,
file.ServerFileName,
file.SizeInKB,
file.UploadDate,
file.UploadUserId);
return historyCreated;
}
示例2: RestoreHistoryFile
public static bool RestoreHistoryFile(
int historyId,
IFileSystem fileSystem,
string virtualSourcePath,
string virtualHistoryPath)
{
bool historyRestored = false;
if (string.IsNullOrEmpty(virtualSourcePath)) { return historyRestored; }
if (string.IsNullOrEmpty(virtualHistoryPath)) { return historyRestored; }
if (fileSystem == null) { return historyRestored; }
int itemId = 0;
int moduleId = 0;
string historyFriendlyName = string.Empty;
string historyOriginalName = string.Empty;
string historyServerName = string.Empty;
DateTime historyUploadDate = DateTime.Now;
int historyUploadUserID = 0;
int historyFileSize = 0;
using (IDataReader reader = SharedFile.GetHistoryFileAsIDataReader(historyId))
{
if (reader.Read())
{
itemId = Convert.ToInt32(reader["ItemID"]);
moduleId = Convert.ToInt32(reader["ModuleID"]);
historyFriendlyName = reader["FriendlyName"].ToString();
historyOriginalName = reader["OriginalFileName"].ToString();
historyServerName = reader["ServerFileName"].ToString();
historyFileSize = Convert.ToInt32(reader["SizeInKB"]);
historyUploadUserID = Convert.ToInt32(reader["UploadUserID"]);
historyUploadDate = DateTime.Parse(reader["UploadDate"].ToString());
}
}
SharedFile sharedFile = new SharedFile(moduleId, itemId);
CreateHistory(sharedFile, fileSystem, virtualSourcePath, virtualHistoryPath);
//File.Move(Path.Combine(historyPath, Path.GetFileName(historyServerName)), Path.Combine(sourcePath, Path.GetFileName(historyServerName)));
fileSystem.MoveFile(
VirtualPathUtility.Combine(virtualHistoryPath, historyServerName),
VirtualPathUtility.Combine(virtualSourcePath, historyServerName),
true);
sharedFile.ServerFileName = historyServerName;
sharedFile.OriginalFileName = historyOriginalName;
sharedFile.FriendlyName = historyFriendlyName;
sharedFile.SizeInKB = historyFileSize;
sharedFile.UploadDate = historyUploadDate;
sharedFile.UploadUserId = historyUploadUserID;
historyRestored = sharedFile.Save();
SharedFile.DeleteHistory(historyId);
fileSystem.DeleteFile(VirtualPathUtility.Combine(virtualHistoryPath, historyServerName));
return historyRestored;
}