typestar

Files in Visual Basic

Write, append, stream and delete through System.IO.

Imports System.IO

Dim target = Path.Combine(Path.GetTempPath(), "typestar_notes.txt")
File.WriteAllLines(target, {"first line", "second line"})
File.AppendAllText(target, "third line" & Environment.NewLine)

For Each line In File.ReadLines(target)
    Console.WriteLine($"> {line}")
Next

Console.WriteLine($"bytes on disk: {New FileInfo(target).Length}")
File.Delete(target)
Console.WriteLine($"still there: {File.Exists(target)}")

How it works

  1. Path.Combine builds the temp-file path portably.
  2. WriteAllLines creates; AppendAllText extends without clobbering.
  3. File.ReadLines streams lazily — no whole-file array needed.
  4. FileInfo reports size; Delete and Exists close the loop.

Keywords and builtins used here

The run, in numbers

Lines
13
Characters to type
429
Tokens
95
Three-star pace
85 tpm

At the three-star pace of 85 tokens a minute, this run takes about 67 seconds.

Type this snippet

Step 1 of 3 in Files & errors, step 25 of 29 in Language basics.

← Previous Next →

Files in other languages