private void CreateDirectoryIfNeeded(string directory) { if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } }