// Applies the avatar image once the user chooses to Save changes public void applyAvatar() { var file_path = Node.localStorage.getOwnAvatarPath(false); var source_file_path = Path.Combine(Node.localStorage.avatarsPath, "avatar-tmp.jpg"); // Check if the source file exists before proceeding if (!File.Exists(source_file_path)) { return; } // Remove the avatar image first if (File.Exists(file_path)) { File.Delete(file_path); } File.Copy(source_file_path, file_path); // Delete the temporary avatar image if the copy was successfull if (File.Exists(file_path)) { File.Delete(source_file_path); } FriendList.broadcastAvatarChange(); }