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


C# IFileSystem.MoveFile方法代码示例

本文整理汇总了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;
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:25,代码来源:SharedFilesHelper.cs

示例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;
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:59,代码来源:SharedFilesHelper.cs


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