I have encountered a very strange behavior on the computer of one of my clients and I cannot find any clue as to why it happens:
When the application calls Environment.GetFolderPath(Environment.SpecialFolders.ApplicationData)
the return value will be C:
.
This is of course wrong, his AppData directory is the usual C:\Users\.....\AppData\Roaming
and also his variable %APPDATA%
points to exactly that directory.
Can anybody shed light on why this could possibly happen?
EDIT: The code...
LogFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ReportsAddin";
if (!Directory.Exists(LogFilePath) && Properties.Settings.Default.Logging == true)
{
try
{
Directory.CreateDirectory(LogFilePath);
}
catch (Exception ex)
{
// ...
}
}
The exception thrown then says that it cannot create a directory consisting of a blank string or blank spaces. Investigating with some output showed that the AppData folder returning from that call is C: when in fact it should be the user's real AppData folder.