vb.net linked vs embedded resources weird result - VS 2017 CE - vb.net

This suppose to be a simple issue; not to be posted as a question in stack overflow!
Following this article: How to: Create Embedded Resources
I had created a new and fresh Form1.vb to test in Visual Studio 2017 community edition.
Added a big testfile.WAV file as a test resource.
Checked the link type is set to default value: "Linked at compile
time" Default Value.
Clean/Build/Rebuild the application.
Still no matter what I do, the result.exe file is so big and reflect the big testfile.wav file size, and can't at any situation find the wav file as a linked resources in separate file in bin\Debug folder!
Tried to alter almost everything everywhere; yet no success!
What I expect is to have both result.exe and testfile.wav in bin\Debug folder separately linked and not embedded.
Looks very weird to me? is it a bug in VS or in app setting?
Thank you so much
Appreciated any hint
Note: What I was trying to reach is to create a different themes for my application, where users can chose the appearance; and my efforts break in the above scenario. It doesn't make sense that result.exe ends in 10s of MB if it will include resources inside it!

TL;DR: If you want it as a loose file then you need to have it as a loose file. Resources are always embedded in the application.
If you add the resource via Project Properties > Resources then it will always be embedded in your application.
If you want it as a loose file then you shall just import it to your project via Add Existing Item and set the Copy to Output Directory property of the item to Copy Always. Then you reference it by doing for example:
Dim WavPath As String = Path.Combine(Application.StartupPath, "yourfile.wav")
Dim WavFile As Byte() = File.ReadAllBytes(WavPath)
Linked vs Embedded only make a difference at design time. Linked resources are still embedded in your application, but at design time you may edit them and can easily add or remove other resources.
Embedded resources however are embedded in a .resx file even at design time, and to edit such resources you have to export them or change them into a linked resource. Embedded resources are mostly used when you need to share the same resources in multiple projects. The resources are then embedded in the .resx file so you only need to copy that and not every included file.

Related

Programmatically set default column values based on folder in SharePoint Online

I'm working on enhancing metadata in our SharePoint online (O365) environment. Since a portion of my user base is used to foldering (explorer style), I've started using default column values to automatically set values on any files added to that specific folder (we have content organized categorically by folder currently). An example is our HR documents library - we have separate folders for recruiting, payroll, personnel files, etc. that automatically categorize files added to that folder with the same categories (recruiting, payroll, personnel, etc.). This supports both "search" and "click" users and makes adoption WAY easier while getting important metadata.
I want to implement this in a larger, more dynamic fashion, so manually setting default column values on each folder is not going to be scalable.
How can I reference the top level folder within the library (or even the current folder) for each newly added file and populate the "category" field for that new file with that folder name? I can do some very basic C# or Java code copy/paste, but bonus points for non-coding solutions =)
This problem can be solved through no coding.You can use the workflow to implement this by SharePoint Designer.
Create different view for different function team, and then use the view filter to show the document.
If you upload a file, use the workflow to set the metadata of the file. There are some known limitations: if you upload multiple files at the same time, the metadata for the file maybe does not work well; or if you upload a folder, the meta will not work for it and the file in the folder may not be set to right metadata.
I was actually able to use MS Flow to accomplish this in a pretty simple and straightforward fashion without managing custom views per team. The concept at a high level was:
(Trigger) When a new document is created in a folder in the library
Get the link of the parent folder of the newly added document
Create a variable (or just code it out in the Flow step) to parse out the name of the parent folder from the parent folder link (should be all text to the right of the last "/")
Set the category field as the variable
I'm sure that you could do the same right in a SharePoint designer workflow, but I prefer flow due to the visual aspect of it and being far easier to troubleshoot.

Visual Studio Unit Test Data Path and Source Control

I have a unit test project for my VB.NET solution that takes a very large data set (multiple Gigabytes). The data set is static, outside of source control (developers unzip a big .zip file somewhere on their machine)
I'm trying to figure out how to reference this data set inside my project and I'm having trouble because of the following constraints:
The data set may be in a different location on each developer's machine e:\dev\MySolution\TestProject\ vs. c:\MySolution\TestProject\data. We can require it to be in the project folder but I can't require that the project folder be in the same place. This means I can't store the path in source control or I need some way to override it.
Because of its size I don't want to have to copy or deploy the test data at runtime because this will slow things down a lot and I don't want to have two copies of it.
My hack-y solution is to use a project property called DataPath and reference this inside each test. Then users would just change the property and I'd instruct them not to commit this change.... feels like an anti-pattern though.
My initial thoughts were to somehow store the path in the project.suo file which is outside of source control but I can't figure out how to make that work.
Anyone have experience with this?

VB.NET Create downloadable resource

I've become stuck at this hurdle. I'm trying to create a database that clients fill in, however the client can set different database paths to view different information in the program. I want to create template databases so should they wish to create a new database it will work with the SQL queries the program uses.
I'm trying to save the templates in to the program so that when a button is clicked, the template file is "downloaded" (copied) to the clients desktop.
Is this even possible?
Thanks
You can open the Resources page of the project properties and add any existing file, including a SQL Server MDF data file. At run time, you can get the data of the file from the appropriate property of My.Resources. The type of the data depends on the type of the file. I'd expect that an MDF file would come back as a Byte array, which you can then write to a file or whatever.
That said, you don't want to make your EXE too big by embedding several sizeable data files in it. You might be better off just using loose files in a subfolder or, if you're determined to use resources, create a satellite assembly, i.e. a DLL that contains just resources.

Need VB.NET Resource Files clarification

In a VB project I can add a resource via the project properties resources tab, or I can right-click the project in the solution explorer, click add, then click add existing item.
What are the differences?
If I want to add a DLL file and include it as an embedded resource, do I have to add the file via both methods? Only one?
Thanks.
What you are describing is linked and embedded resources.
Check out this page which describes the differences:
Linked vs. Embedded Resources
From the MSDN link above:
Embedded Resources
Embedded resources are the best choice if you need to share application resource (.resx) files between multiple projects.
For example, if you have a common resource file that contains your company's logos, trademark information, and such, using embedded resources means you only have to copy the .resx file and not the associated resource data files.
You cannot edit embedded resources directly. If you try to edit an embedded resource, you will receive a message prompting you to convert the item to a linked resource in order to edit it; conversion is recommended but optional. You must export them, make your modifications in an external program, and then import them back into your project.
Linked Resources
Linked resources (the default) are the best choice for ease of use.
Resources can be edited directly inside the project, and you can easily add or remove resources as needed.
Edit
You would only need to add your DLL using one method. Which one you select depends on which method best fits your needs (as per the descriptions above)

NSBundle, can it be used to save a project document?

I'm building a Mac OS X application that can be used to create 'projects'. When a user saves a project, they will be saving many resources: image files, text files, sqlite files etc.
I can either create a folder in Documents for each project, and within that folder I can place all the project assets, and just include a single project file that is used to open the project.
I've read about NSBundle which I'd like to use. But I've only read about them in the context of application bundles. Is it possible to use NSBundle in this way? Where the user only sees a single file, and can move it wherever they like.
Does it make sense to do what I'm trying, using NSBundle? Or is there another way to do this?
(I'm fairly new to MacOS X programming)
UPDATE
I believe iPhoto uses this method to store the "iPhoto Library", this is what I'd like to do with my application, is NSBundle what I should be looking into?
Yes, it is possible and was used in quite a few apps in the past. The method is described in this document. Once it's clearly declared in your app's Info.plist, Finder will show the resulting bundle as one file.
However, I can't recommend you to do that. Apple's own Keynote was using the bundle approach in the past, but it no longer uses it any more. Similarly, OmniGraffle (which is a diagramming app on OS X with a long history) used bundles to save projects, but it stopped doing that, too.
The reason is that the bundle is still seen as a directory by the non-Apple email software, or any browser, etc, although the Finder shows it as a file. It would be a mess if a user wants to attach your document in the bundle format to an email s/he is composing in Gmail inside a browser, say. That confused a lot of people.
So, it's possible, but I don't recommend it. One way out is to use the zipped bundle as the user-visible file, and to unzip it when the user opens it into a temporary directory. Then you can use NSBundle and/or NSFileWrapper apis to access files inside it.
Apple's File Wrapper sample seems to be what you want:
http://developer.apple.com/library/mac/#samplecode/PersistentDocumentFileWrappers/Introduction/Intro.html
It also demonstrates how to save a Core Data persistent store in the bundle. You can leave that part out if you just want to store resources.
The NSBundle class represents the application bundle, and can be used to access resources within the applicationm but you would you it for application data, not user data.
For each of the resources you mention, there's a way of saving this type, for example, for image files, you could use NSData to save the image data to disk, and for text files you could use the method writeToFile:atomically:encoding:error:.
You may very well want to take a look at Core Data (http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreData/cdProgrammingGuide.html), a very good framework for managing the user's data model, to see if this would fit your needs.