Skip to content
Merged
19 changes: 19 additions & 0 deletions src/DynamoCoreWpf/Utilities/WebView2Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Dynamo.Configuration;
using Dynamo.Models;
using Dynamo.Wpf.Properties;
using DynamoUtilities;
Expand Down Expand Up @@ -103,5 +106,21 @@ public static bool ValidateWebView2RuntimeInstalled()
return false;
}
}

/// <summary>
/// Returns the user data folder path for WebView2 (used in SplashScreen, HomePage, PackageManagerWizard)
/// </summary>
/// <returns>user data folder path for WebView2</returns>
internal static string GetTempDirectory()
{
// Create a temp folder unique to this Dynamo instance based on process id
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string tmpDataFolder = Path.Combine(
localAppData,
"Temp",
Configurations.DynamoAsString,
"WebView2");
return tmpDataFolder;
}
}
}
6 changes: 1 addition & 5 deletions src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ private void DynamoViewModel_PropertyChanged(object sender, System.ComponentMode
/// <returns></returns>
private static string GetUserDirectory()
{
var version = AssemblyHelper.GetDynamoVersion();

var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
return Path.Combine(Path.Combine(folder, "Dynamo", "Dynamo Core"),
String.Format("{0}.{1}", version.Major, version.Minor));
return WebView2Utilities.GetTempDirectory();
}

private async void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,7 @@ internal bool ProcessUri(string uri)
/// <returns></returns>
private static string GetUserDirectory()
{
var version = AssemblyHelper.GetDynamoVersion();

var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
return Path.Combine(Path.Combine(folder, "Dynamo", "Dynamo Core"),
String.Format("{0}.{1}", version.Major, version.Minor));
return WebView2Utilities.GetTempDirectory();
}

/// <summary>
Expand Down
6 changes: 1 addition & 5 deletions src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,7 @@ private void DynamoModel_RequestUpdateLoadBarStatus(SplashScreenLoadEventArgs ar
/// <returns></returns>
private string GetUserDirectory()
{
var version = AssemblyHelper.GetDynamoVersion();

var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
return Path.Combine(Path.Combine(folder, Configurations.DynamoAsString, "Dynamo Core"),
String.Format("{0}.{1}", version.Major, version.Minor));
return WebView2Utilities.GetTempDirectory();
}

protected override async void OnContentRendered(EventArgs e)
Expand Down
Loading