add nativ webview
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Compression;
|
||||
using System.IO;
|
||||
using System.DirectoryServices;
|
||||
using System.ServiceModel.Configuration;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
@@ -15,13 +19,90 @@ namespace Project
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
|
||||
// Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
||||
// AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
|
||||
var fi = new System.IO.FileInfo("WebView2Runtime.zip");
|
||||
if (fi.Exists)
|
||||
{
|
||||
var existlen = 0;
|
||||
var webruntimepath = new System.IO.DirectoryInfo("WebView2Runtime");
|
||||
if (webruntimepath.Exists)
|
||||
{
|
||||
var filen = new System.IO.FileInfo("WebView2Runtime\\version.txt");
|
||||
if(filen.Exists)
|
||||
{
|
||||
var verstr = System.IO.File.ReadAllText(filen.FullName);
|
||||
int.TryParse(verstr, out existlen);
|
||||
}
|
||||
}
|
||||
if(existlen != fi.Length)
|
||||
{
|
||||
//fi 파일의 압축을 해제한다.
|
||||
var fprogress = new Dialog.fUnZip();
|
||||
fprogress.TopMost = true;
|
||||
fprogress.Show();
|
||||
Application.DoEvents();
|
||||
try
|
||||
{
|
||||
if (webruntimepath.Exists)
|
||||
{
|
||||
fprogress.label1.Text = "기존폴더삭제";
|
||||
Application.DoEvents();
|
||||
webruntimepath.Delete(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
var diruntime = new System.IO.DirectoryInfo("runtimes");
|
||||
if (diruntime.Exists) diruntime.Delete(true);
|
||||
webruntimepath.Create();
|
||||
diruntime.Create();
|
||||
|
||||
|
||||
using (var archive = ZipFile.OpenRead(fi.FullName))
|
||||
{
|
||||
int totalFiles = archive.Entries.Count;
|
||||
int currentFile = 0;
|
||||
long totalSize = archive.Entries.Sum(e => e.Length);
|
||||
long extractedSize = 0;
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
currentFile++;
|
||||
extractedSize += entry.Length;
|
||||
int progress = (int)((extractedSize * 100) / totalSize);
|
||||
|
||||
fprogress.label1.Text = $"압축 해제 중... ({currentFile}/{totalFiles})";
|
||||
fprogress.label2.Text = $"{entry.FullName} ({progress}%)";
|
||||
fprogress.progressBar1.Value = progress;
|
||||
Application.DoEvents();
|
||||
|
||||
string destinationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, entry.FullName);
|
||||
string destinationDir = Path.GetDirectoryName(destinationPath);
|
||||
|
||||
if (!Directory.Exists(destinationDir))
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
if (entry.Length > 0)
|
||||
entry.ExtractToFile(destinationPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
System.IO.File.WriteAllText("WebView2Runtime\\version.txt", fi.Length.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
fprogress.Hide();
|
||||
MessageBox.Show($"WebView2 Runtime 압축 해제 중 오류가 발생했습니다: {ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally {
|
||||
fprogress.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
|
||||
|
||||
Application.Run(new fMain());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user