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


C# IFileSystem.ReadAllLines方法代码示例

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


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

示例1: Scope

            public Scope(IFileSystem fileSystem, string databaseFile)
            {
                _fileSystem = fileSystem;
                _databaseFile = databaseFile;

                _allSeen = _fileSystem.ReadAllLines(SeenPath);
                _allGone = _fileSystem.ReadAllLines(GonePath);
                _currentSnapshot = _fileSystem.ReadAllLines(CurrentPath);
            }
开发者ID:Mattybritt,项目名称:duplicatefinder,代码行数:9,代码来源:DatabaseHistory.cs

示例2: ExecuteChanges

        /// <summary>
        /// Executes the changes recorded for the associated file in chronological order.
        /// </summary>
        public override void ExecuteChanges(IFileSystem fileSystem)
        {
            string newPath;

            if (fileSystem.IsDirectory(AssociatedPath) && _newName != null)
            {
                string tmp = AssociatedPath.Substring(0, AssociatedPath.Length - FileSystem.PathSeparator.Length);
                newPath = "\\" + tmp.Substring(0, tmp.LastIndexOf("\\")) + "\\" + _newName;
                newPath = newPath.Replace("\\\\", "\\");
                fileSystem.Move(AssociatedPath, newPath);
                return;
            }

            String[] fileContent = fileSystem.ReadAllLines(AssociatedPath);
            IList<String> updatedFileContent = new List<String>();

            if (_newName != null)
            {
                newPath = AssociatedPath.Substring(0, AssociatedPath.LastIndexOf("\\")) + "\\" + _newName;
                newPath = newPath.Replace("\\\\", "\\");
                fileSystem.Move(AssociatedPath, newPath);
            }
            else
            {
                newPath = AssociatedPath;
            }

            if (_modificationList.Count > 0)
            {
                int contentPointer = 0;
                foreach (AbstractModification modification in _modificationList)
                {
                    for (; contentPointer < modification.LineNumber && contentPointer < fileContent.Length; contentPointer++)
                    {
                        updatedFileContent.Add(fileContent[contentPointer]);
                    }
                    if (modification is DeletionModification)
                    {
                        if (modification.LineNumber != contentPointer)
                            Debug.WriteLine("modification.LineNumber != contentPointer => " + modification.LineNumber + ", " +
                                            contentPointer);

                        contentPointer++;
                    }
                    else if (modification is InsertionModification)
                    {
                        InsertionModification insertion = modification as InsertionModification;
                        updatedFileContent.Add(insertion.Line);
                    }
                }
                fileContent = updatedFileContent.ToArray();
            }
            fileSystem.WriteAllLines(newPath, fileContent);
        }
开发者ID:Yndal,项目名称:BDSA-Project-2012,代码行数:57,代码来源:FileModifiedChange.cs


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