I have written a winform app and have created a installation program using Inno Setup so that a custom file extension is associated with it.
The application is setup so that if the associated file type is double clicked then the application automatically opens and loads the file. This works fine from if the file is double clicked from the desktop or file explorer.
However, we have noticed an issue when trying to open a file attachment from inside Outlook. This error is being generated:
System.UnauthorizedAccessException
I have caught the error in my application and checked the file path that is supplied to the program. It doesn't exist in the file system (when I try to browse to it).
C:\User\MyUserName\AppData\Local\Microsoft\Windows\INetCache\Content.Outlook\MXIIIP00\MyFilename.CustomExtension
The section after ...\Microsoft\Windows\ doesn't exist (as far as I can see).
Has anyone else encountered this issue and know how to solve it?
UPDATE:
If I open a dos prompt - I can actually get to this location even though it is not shown in Windows Explorer.
UPDATE 2:
If I copy the path directly into Windows Explorer I can see the files here too. However if I double click the file from here - my application still cannot load the file.
UPDATE 3:
The file saved by Outlook (and that my app is trying to open) appears to be empty. Which would explain why my app can't process it. Outlook appears to be doing something to the file when I send it. It starts off as 72KB when I send it, but when I receive it - it is 252B.