Which word you don't understand in
System.IO.IOException: 'The process cannot access the file 'D:\chart\86e740b9-83bc-470e-9e03-efa9864b1d8e.jpg' because it is being used by another process.'
By design, the OS forbid you from deleting a file in use.
Solution, wait until the file is not in use anymore.