04-22-2012, 06:36 PM
ok like this u make it extract form the resource for example now the ZipForge.dll
first add the dll file to resources and set the settings to it as embedded resource (Eingebettete Ressource)
apply this code to Form load
and edit it to ur dll file
using System.Reflection;
using System.IO;
...
private void Form1_Load(object sender, EventArgs e)
{
// Edit here
string DllName = "ZipForge.dll";
string resourcephat = "Launcher2_1.Resources.ZipForge.dll";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (File.Exists(DllName) == false)
{
// if the dll is missing it get extrakted
Assembly assembly = Assembly.GetExecutingAssembly();
// Namespace.Resources.Dllfilename.dll
Stream file = assembly.GetManifestResourceStream(resourcephat ); // my resource
BinaryReader bReader = new BinaryReader(file);
FileStream fStream = new FileStream(@System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + DllName , FileMode.Create); // where i want to copy the resource
using (BinaryWriter bWriter = new BinaryWriter(fStream))
{
bWriter.Write(bReader.ReadBytes((int)file.Length));
bReader.Close();
bWriter.Close();
}
file.Close();
fStream.Close();
}
}

