Hi,
I'm trying to locate resources following checking 'Resources Compression and Encryption' (in SmartAssembly Professional 6.8.0.121) and while I can reach them by directly naming them, I'm unable to using LINQ to collect a sub-set - something I was able to do prior to using the feature.
Below is an example snippet that demonstrates the problem. 'btnReadResources_Click' returns the expected results, but 'btnFindResources_Click' does not. Is there a good way around this problem, where I can filter the available encrypted resources based on part of the namespace?.
Best regards
John
private void btnReadResources_Click(object sender, RoutedEventArgs e)
{
var assembly = Assembly.GetExecutingAssembly();
txtAOutput.Text = "";
txtBOutput.Text = "";
txtAOutput.Text = txtAOutput.Text + "\n" + GetResText(assembly, "TestEmbeddedResources.MyResFolder.A.FldrA1.TxtA1.txt");
txtAOutput.Text = txtAOutput.Text + "\n" + GetResText(assembly, "TestEmbeddedResources.MyResFolder.A.FldrA2.TxtA2.txt");
txtAOutput.Text = txtAOutput.Text + "\n" + "[Done]";
txtBOutput.Text = txtBOutput.Text + "\n" + GetResText(assembly, "TestEmbeddedResources.MyResFolder.B.FldrB1.TxtB1.txt");
txtBOutput.Text = txtBOutput.Text + "\n" + GetResText(assembly, "TestEmbeddedResources.MyResFolder.B.FldrB2.TxtB2.txt");
txtBOutput.Text = txtBOutput.Text + "\n" + GetResText(assembly, "TestEmbeddedResources.MyResFolder.B.FldrB3.TxtB3.txt");
txtBOutput.Text = txtBOutput.Text + "\n" + "[Done]";
}
private void btnFindResources_Click(object sender, RoutedEventArgs e)
{
var assembly = Assembly.GetExecutingAssembly();
txtAOutput.Text = "";
txtBOutput.Text = "";
var stdResNames = assembly.GetManifestResourceNames()
.Where(name => name.StartsWith("TestEmbeddedResources.MyResFolder.A."));
foreach (var stdResName in stdResNames)
{
AddResString(txtAOutput, GetResText(assembly, stdResName));
}
AddResString(txtAOutput, "[Done]");
var proResNames = assembly.GetManifestResourceNames()
.Where(name => name.StartsWith("TestEmbeddedResources.MyResFolder.B."));
foreach (var proResName in proResNames)
{
AddResString(txtBOutput, GetResText(assembly, proResName));
}
AddResString(txtBOutput, "[Done]");
}
private string GetResText(Assembly assembly, string resName)
{
string result;
using (var stream = assembly.GetManifestResourceStream(resName))
using (var reader = new StreamReader(stream))
{
result = reader.ReadToEnd();
}
return result;
}
private void AddResString(TextBox txtBx, string strRes)
{
txtBx.Text = txtBx.Text + "\n" + strRes;
}
I'm trying to locate resources following checking 'Resources Compression and Encryption' (in SmartAssembly Professional 6.8.0.121) and while I can reach them by directly naming them, I'm unable to using LINQ to collect a sub-set - something I was able to do prior to using the feature.
Below is an example snippet that demonstrates the problem. 'btnReadResources_Click' returns the expected results, but 'btnFindResources_Click' does not. Is there a good way around this problem, where I can filter the available encrypted resources based on part of the namespace?.
Best regards
John