Embed Dictionary into VB.NET application - vb.net

I want to embed a dictionary.txt which my program uses a streamreader object to parse. I tried to add it to resources but then the streamreader had an error. How can it be properly done?
Thanks

First you need to embed the file in your assembly (add to project and goto Properties for the file, and set Build Action to "Embedded Resource").
Then you need to access and read it's contents using GetManifestResourceStream():
Getting an embedded resource file out of an assembly
This article might be of interest: Microsoft .NET Framework Resource Basics

Related

Resource Files in CF - Not Embedded

I have a PPC2003 project in VS2005. I have added a resource file (SomeResources.resx) to the project. I can access the test string I have in the file by using My.Resources.SomeResources.MyTestString (I am using the default Custom Tool Name that VS provides).
When the Build Action property of the is set to Embedded Resource, the application references the MyTestString successfully.
But I do not want to embed the file, so that it's string values can be modified after it has been deployed/installed.
I, therefore, changed the Build Action to Content, so that the file gets copied out to the device for potential future manipulation. When I call MyTestString I get the following error:
MissingManifestResourceException Stack Trace: at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.InternalGetResourceSet() at System.Resources.ResourceManager.GetString() at MyApp.My.Resources.SomeResources.get_MyTestString() at MyApp.fMain.fMain_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at MyApp.fMain.Main()
As the file is not embedded, do I maybe need to manually load it first? If so, how? Any other ideas? Is it not possible to do what I'm after achieving and should I just create my own XML file/reader?
Resources (resx files) are specifically designed to be compiled into the application. If you want it to be an editable content file on the target, then you have to approach it differently and use something like an XML file and wrap that with accessors (akin to the Configuration namespace stuff in the full framework).

How to access a specific resw resource file

For a Windows 8 application in C#/XAML I need to access a specific ressource file. In WP7 I used resx file and now it seems that we need to use resw file. It's not a language resource file.
My file is called ConfigResources.resw, it just contains one key : "ConfigFile" and a value : a string.
How can I access it from my code? I tried this without any luck:
var storedConfigFile = Application.Current.Resources["ConfigResources"];
Then how can I edit the value of the key inside from my code?
Thank you
I created a project on CodePlex recently called ResW File Code Generator that simplifies using localized resources in code in windows store app project. It's a custom tool that automatically generates and updates a helper class similar to what ResX files used in the full version of .NET
According to here, you need to use the Windows.ApplicationModel.Resources.ResourceLoader and the Windows.ApplicationModel.Resources.Core namespace provide interaction with resw files.
It should look something like this:
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
var text = loader.GetString("Farewell");
Alternately, if you're creating a cross-platform library you could also do it using the System.Resources.ResourceManager:
Although the System.Resources.ResourceManager class is included in the
.NET for Windows Store apps, we do not recommend its use. Use
ResourceManager only in libraries that are developed as Portable Class
Library projects and that target multiple platforms.
Like this from here:
ResourceManager rm = new ResourceManager("Strings", typeof(Example).Assembly);
string timeString = rm.GetString("TimeHeader");
There is a sample that shows the different ways to read the resources in WinRT apps (i.e. from resw files).

Where can I get Tridion.ContentManager.Data.ContentManagement DLL?

I want to access "Fields" property for accessing fields of a schema in core services in SDL Tridion but Visual Studio says I am missing an assembly reference.
I searched for namespace and it requires Tridion.ContentManager.Data.ContentManagement DLL. Where can I find this DLL?
There's no Fields property on CoreService. If you see it - you probably have mixed references to TOM.NET and CoreService. You need only reference to CoreService client dll and nothing more. If you wan't to have something similar to Fields implementation - you may take a look at this article: http://code.google.com/p/tridion-practice/wiki/ChangeContentOrMetadata
If you want to have the Tridion.ContentManagement.Data.DLL just do this:
Open cmd from Run
Navigate to C:\Windows\assembly\GAC_MSIL\Tridion.ContentManager.Data\6.1.0.996__ddfc895746e5ee6b>
Copy the file to a folder you want

Visual Studio Custom Tool: File wrapper

What I want is typed access to the contents of a file within a VS.NET solution.
I think a custom tool with corresponding custom tool namespace would be the easiest to do (do correct me if there is a simpler way of accomplishing the same thing!)
This would generate code like so:
Namespace CustomToolNamespaceInPropertiesComesHere
Public Module SomeName
Public Function GetFile() As IO.Stream
Return System.Reflection.Assembly.GetExecutingAssembly() _
.GetManifestResourceStream("RootNamespace.FileName.xml")
End Function
End Module
End Namespace
Basically it creates typed access to a file (An XML file with Build Action: Embedded Resource) within the "Custom Tool Namespace" as specified in the properties of the file.
I do not want to use a ResX as I want each XML file to appear seperately in the solution and have the XMLEditor as default editor (So XSD validation can be added if time permits writing one).
Unfortunately little information can be found about these custom tool namespaces. Every example so far also seems to refer to BaseCodeGeneratorWithSite of which the original URL has gone dead.
I'm also asking this in hopes of someone providing something easier to use/implement rather than the overkill of a new custom tool...

Access .exe file in resources?

I have an encrypted program in my resources in a project I'm working on and I need to access that file like this.
Dim fs As New FileStream(filepath, FileMode.Open)
Any help?
try GetManifestResourceStream - it gives you a stream to read the resource by name. This stream can be used for example to decrypt and/or write to a real file and/or load as an Assembly (if the embedded resource is a .NET exe/DLL)...
For sample code see http://www.eggheadcafe.com/microsoft/VB-NET/33899321/how-to-extract-a-resource-to-a-file.aspx .