Task

Delete a file called "input.txt" and delete a directory called "docs".

This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.




using System;
using System.IO;
using System.Console;
 
module DeleteFile
{
    Main() : void
    {
        when (File.Exists("input.txt")) File.Delete("input.txt");
        try {
            when (File.Exists(@"\input.txt")) File.Delete(@"\input.txt");
        }
        catch {
            |e is UnauthorizedAccessException => WriteLine(e.Message)
        }
 
        when (Directory.Exists("docs")) Directory.Delete("docs");
        when (Directory.Exists(@"\docs")) Directory.Delete(@"\docs");
    }
}