Most of the applications consuming my add-in return "C:\Users\[username]\AppData\Local\Temp\" path. But one application is returning "C:\Users\[username]\AppData\Local\Temp\1affa5dd-2f26-4c96-9965-7a78f5c76321\". The GUID in the end changes every time I launch the application.
The application that I am running my add-in from are Revit 2015-2020. Revit versions 2015-2019 return the correct path. But Revit 2020 is returning the path with GUID appended in the end. The code remains the same.
public static string GetLocalFilePath(string sourceUri, string fileName, string extension)
{
string[] sasTokenSeparated = sourceUri.Split('?');
string[] uriParts = sasTokenSeparated[0].Split('/');
string documentId = uriParts[uriParts.Length - 2];
documentId = documentId.Split('.')[0];
string extensionWithDot = string.Empty;
if (!extension.StartsWith("."))
{
extensionWithDot = "." + extension;
}
else
{
extensionWithDot = extension;
}
string localPath = Path.Combine(Path.GetTempPath(), documentId, fileName + fileExtension);
return localPath;
}
I am expecting the path, "C:\Users\[username]\AppData\Local\Temp\"
While I am actually getting path, "C:\Users\[username]\AppData\Local\Temp\1affa5dd-2f26-4c96-9965-7a78f5c76321\"
%TMP/TEMP%
Environment Variable. – IamsPath.Combine(System.Environment.GetEnvironmentVariable("LOCALAPPDATA"), "Temp")
– Iams