Remaetanju
Remaetanju
CC#
Created by Remaetanju on 1/2/2024 in #help
AOT Compilation trimming
hi, i have a nuget package that i use in my code (a client api to download from mega) when i AOT compile my code, it runs but there is an exception It catches that tell me the package doesnt work (simple login anon that should not fail) I think the trimmer remove too much code from the nuget package, causing it to breaks is there an option to exclude this nuget package from being trimmed ? so i could test it im on .net 8.0
8 replies
CC#
Created by Remaetanju on 12/28/2023 in #help
Forms ProgressBar with MegaApiClient download
using thoses resources: https://gpailler.github.io/MegaApiClient/articles/samples.html https://gpailler.github.io/MegaApiClient/articles/faq.html => download a file hosted by mega & show a forms progress bar - the download is NOT ASYNC - c# 6.0 the download works i'm not sure how to adapt the progress bar system from mega to a windowsforms progress bar

internal static class Program
{
private const string packurl = "https://mega.nz/file/R1pgBAAI#CDFU6xx9EwCEZJ1Z0vKfl_o9DNtPBNjllpuAVZ38nn4";
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
// downloaded zip name
string LCGamePath = "F:\\Games\\Steam\\steamapps\\common\\Lethal Company";
string packname = "MedalCompany.zip";
// setupprogress bar
ProgressBar pBar1 = new();
// Display the ProgressBar control.
if (pBar1 == null)
return;
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1.Maximum = 100;
// Set the initial value of the ProgressBar.
pBar1.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
pBar1.Step = 1;
// MegaApi Anonymous login
MegaApiClient client = new MegaApiClient();
client.LoginAnonymous();
Uri fileLink = new Uri(packurl);
INode node = client.GetNodeFromLink(fileLink);

void performstep()
{
pBar1.PerformStep();
pBar1.Show();
}
using (var downloadStream = client.Download(node))
using (var progressionStream = new ProgressionStream(downloadStream, x => performstep()))

using (var fileStream = new FileStream(LCGamePath + "\\" + packname, FileMode.Create))
{ progressionStream.CopyTo(fileStream);
}
client.Logout();
}
}

internal static class Program
{
private const string packurl = "https://mega.nz/file/R1pgBAAI#CDFU6xx9EwCEZJ1Z0vKfl_o9DNtPBNjllpuAVZ38nn4";
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
// downloaded zip name
string LCGamePath = "F:\\Games\\Steam\\steamapps\\common\\Lethal Company";
string packname = "MedalCompany.zip";
// setupprogress bar
ProgressBar pBar1 = new();
// Display the ProgressBar control.
if (pBar1 == null)
return;
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1.Maximum = 100;
// Set the initial value of the ProgressBar.
pBar1.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
pBar1.Step = 1;
// MegaApi Anonymous login
MegaApiClient client = new MegaApiClient();
client.LoginAnonymous();
Uri fileLink = new Uri(packurl);
INode node = client.GetNodeFromLink(fileLink);

void performstep()
{
pBar1.PerformStep();
pBar1.Show();
}
using (var downloadStream = client.Download(node))
using (var progressionStream = new ProgressionStream(downloadStream, x => performstep()))

using (var fileStream = new FileStream(LCGamePath + "\\" + packname, FileMode.Create))
{ progressionStream.CopyTo(fileStream);
}
client.Logout();
}
}
4 replies
CC#
Created by Remaetanju on 12/28/2023 in #help
Trouble reading registry
string value64 = string.Empty;
string value32 = string.Empty;

const string subkey = @"Test";
const string valueName = "Testvalue";

RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
localKey = localKey.OpenSubKey(subkey);
if (localKey != null)
{
value64 = localKey.GetValue(valueName).ToString();
MessageBox.Show(value64);

}
RegistryKey localKey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
localKey32 = localKey32.OpenSubKey(subkey);
if (localKey32 != null)
{
value32 = localKey32.GetValue(valueName).ToString();
MessageBox.Show(value32);

}
string value64 = string.Empty;
string value32 = string.Empty;

const string subkey = @"Test";
const string valueName = "Testvalue";

RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
localKey = localKey.OpenSubKey(subkey);
if (localKey != null)
{
value64 = localKey.GetValue(valueName).ToString();
MessageBox.Show(value64);

}
RegistryKey localKey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
localKey32 = localKey32.OpenSubKey(subkey);
if (localKey32 != null)
{
value32 = localKey32.GetValue(valueName).ToString();
MessageBox.Show(value32);

}
I'm in a lot of trouble to read a single value from the registry i've tried various codes snippets but everytime my code just doesnt find the key
54 replies