C# – How to make a file read-only

There are two ways to programmatically make a file read-only: Here’s an example showing both ways to make a file read-only: Using File.SetAttributes() is useful when you want to manage all of file’s attributes at once. FileAttributes is an enum flag, so you can use bitwise operations to add/remove multiple attributes at once. That’s why … Read more

C# – How to update a file’s contents

There are three ways to update a file’s content: Which option you pick depends on the file’s format and size. For example, if you’re writing to an existing CSV file, you’d append new lines to the end of the file. If you’re updating a JSON file, you’d read all the JSON content, make changes, then … Read more