Good time of day. There is a folder with files in the dll project. How to access these files from the dll class, if not to make them resources (so as not to know in advance the number of these files - otherwise you need to use reflection)?
Related
I finished my app and now I want to create a update system. I have the installer so I can install the application in other machines, it was made with InnoSetup (I don't know if it is the best way, but it worked). I know the basics, I have to compare the current version with a string stored in a in a web server, if it is greater, download the files. Now, what files? Because the InnoSetup gives me these files:
Where are the .xaml (design) files? And the .cs files? Are they compressed in the .exe? For example If I add a few lines to a class, I want to download this class, no the full installer again. Because the final size of my application is 30Mb, if I change some things of a class, I do not want the user to have to download the 30Mb again
In the most basic of terms, when you compile your program the compiler turns your cs and xaml files into machine readable code and puts it all into an exe file.
Yes, if you add a few lines to a class and recompile it, it will rebuild your exe (assuming the class is part of it, and not an external library).
You still have dependency dll files that you need to include, and any other external content that you've included. But once you have all the external files installed, you wouldn't theoretically need to download them again on an update. Only the files that you've updated, ie the exe.
Maybe not possible but I have an application that gets text from a bunch of text files organised in folders which are all included in my project. However I'd love to compile these text files into the exe so that I don't have to lug the folders with the application. Anyway I can do this?
The folders are in a hierarchy i.e. each folder has a txt file and image that my application uses. At the moment they are all set to build as Embedded Resources which I thought would have compiled them in but unfortunately not.
Preferably I love if there was a way I could add the folder rather than each file individually.
"Compilation" means something else.
Anyway, .NET confusingly uses the same terms to describe "embedded resources", which are exposed as resource streams from the assembly, and the more API-friendly resx resources which are then compiled into .resources files that are also stored as embedded resource streams.
If you want to use ResX resources in your project then go Add New Item > Resources (resx), then go to the Files tab and add references to your filesystem files, then build your project. You'll be able to access those files by going typing FooResources.MyFileName in your program's code, assuming you named your resx file FooResources.
I am trying to write a small application, whose only purpose is to copy some folders and .cs source files into a user specified Directory, I can do it easy enough by simply having the application look for the files and folders in its own install directory then copy them to thier destination Directory, but I was wondering if its possible to Embed the Folders and Files into the Application, so that when you run the application it creates or copies the folders and files from the exe app directly to the install directory, rather than searching for them in the apps install directory then copying them over. Basically Im trying to only have a single exe file rather than having an exe file and a bunch of folders and files along side it.
Is this possible to do with just a Windows Form App without using an actual Installer Class?
Yes. Embed the files into the application executable as embedded resources. Then when your application runs, access the embedded files and write them to disk in the desired directory structure.
Here is an example of how to embed and access embedded resources from your application assembly.
http://support.microsoft.com/kb/319292
Sure you can, use the BuildAction property as Content or Resource.
Depending on the number and structure of files/folders, you may also consider embedding one zip file and extracting it with sharpziplib or some such.
the website i'm working on has resource files for a number of languages.
The resources of the website are compiled in the website dll (i think?) and the resources from other, from the website, referenced dll's, are stored in subfolders of the \bin directory.
So i have in the bin my website.dll, and a subfolder called es with the Spanish resources for the website.services project (called website.services.resources.dll) and so on.
Now we have the site live, and there is a wish for a immediate change of one of the items in a resource file.
As my .resx files are compiled, i have to change the resource in the dll.
Is that possible?
Just change the specified item in the rsex file. Compile it again and replace the DLL. I think it will work.
another approach could be to copy up your project to the server, in it's entirety. Then the runtime on the server will compile the app for you. Then when you next make a change to the resx file the runtime will re-compile the app and pickup the change.
Downside to this when you make a change to the resx your users may notice the site stop working and may lose any session variables (if i remember correctly).
I have built a console application that works okay when it references a .exe file from a Program Files, but my users may not have that .exe in their Program Files directory.
I would prefer to keep the package as a single .exe for simplicity, so I was wondering how I can combine the two .exe's into one package.
One thing I thought of is zipping the .exe from the Program Files directory to a temporary location, and I would store the binary data for the zip archive in my console applications source code. Is this the best way to do it or are there better methods?
Note I do not have the source code of the .exe I want to reference in my console application.
You can certainly store extra files in your .exe (or .dll) as embedded resources. Simply change the "build action" for the item in the project to "Embedded Resource". You can retrieve the contents of the file (which could be compressed, if you wished) by using the following:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("stream name")
You could extract the file onto disk to be able to reference it, or you could load it directly with one of the Assembly.Load() variants, so you wouldn't need to ever store it on disk.
Note that if you do choose to extract it and store it on disk, you'll need administrator permissions on Vista and Windows 7 (and properly administered XP) operating systems in order to save the file(s) to the Program Files directory.
You can use GZipStream to compress and decompress files in C#. For more complex compression, you can use other Zip libraries like SharpZipLib.
Take a look at this link: Embedding assemblies inside another assembly
Basically, ILMerge will do what you are asking.