Most useful .NET utility classes developers tend to reinvent rather than reuse [closed]

People tend to use the following which is ugly and bound to fail:

string path = basePath + "\\" + fileName;

Better and safer way:

string path = Path.Combine(basePath, fileName);

Also I’ve seen people writing custom method to read all bytes from file.
This one comes quite handy:

byte[] fileData = File.ReadAllBytes(path); // use path from Path.Combine

As TheXenocide pointed out, same applies for File.ReadAllText() and File.ReadAllLines()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)