System.IO.File.ReadAllLines C# (CSharp) Méthode

ReadAllLines() public static méthode

public static ReadAllLines ( String path ) : String[]
path String
Résultat String[]
        public static String[] ReadAllLines(String path)
        {
            if (path == null)
                throw new ArgumentNullException(nameof(path));
            if (path.Length == 0)
                throw new ArgumentException(SR.Argument_EmptyPath, nameof(path));
            Contract.EndContractBlock();

            return InternalReadAllLines(path, Encoding.UTF8);
        }

Same methods

File::ReadAllLines ( String path, Encoding encoding ) : String[]
File::ReadAllLines ( string path ) : string[]
File::ReadAllLines ( string path, System encoding ) : string[]

Usage Example

Exemple #1
0
        public void RemoveLinesInFile(string filePath, IFileLinePredicate predicate, string destinationPath = null)
        {
            if (destinationPath.IsNull())
            {
                destinationPath = filePath;
            }

            string[] lines      = File.ReadAllLines(filePath);
            int      linesCount = lines.Length;

            List <string> destinationLines = new List <string>();

            for (int r = 0; r < linesCount; r++)
            {
                string oldLine = lines[r];

                if (!predicate.IsTrue(oldLine))
                {
                    destinationLines.Add(oldLine);
                }
            }

            if (predicate.IsSimulation)
            {
                return;
            }

            File.WriteAllLines(destinationPath, destinationLines);
        }
All Usage Examples Of System.IO.File::ReadAllLines