When I use a fixed path, there is no problem with the code.
And according to the error message, the problem is on the wrong path.
Path.GetDirectoryName Method is to get the folder where the file you specify is located.
If label.Text is "d:\test\test.xlsm", then the result of this method will be "d:\test", you need to add a specific file name later.
Also, please don't add single quotes at the beginning and end, it will produce an invalid path.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.