DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

File Read — Example 122

Quick explanation + ready code for: File Read.

C# File Read Back to examples
Back to language
Syntax: File Read in C#. ID: #122

Code

// Node.js example
import fs from "fs";
const txt = fs.readFileSync("README.md","utf8");
console.log(txt.slice(0,120));

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.