I've been able to transfer files from this device to any PC since I've owned it, up until a few days ago. Usually when it is connected by a USB to a PC I will see the drop down notification that will allow me to change the USB connection settings. After restarting my phone, this notification will only stay for about 30 seconds. All the while, the USB continues to charge. When I do get the chance to see this menu, I choose MTP but the changes don't apply and the screen generally doesn't respond, going dark and unresponsive until I press the home icon. In my developer options I've allowed USB debugging, and my USB Configuration as MTP and PTP but that doesn't seem change anything. I've triple checked my USB cords, which have worked in the past and work with other phones. I'm at wit's end! I need help!
One thing you can do is to use the HTC One M8 root toolkit, which allows you to fix most of the phone's problems with a click of a button. I am not very familiar with the HTC toolkit (I have a Nexus) but you should be able to factory reset your phone without wiping data from here.
You can use this method as a last resort if nothing else works. Here are some websites showing how to fix/backup the specific problem:
If these don't work either, call HTC support since it may actually be a problem with the phone.