Philly566196

can anyone help me out with this one

im using vs c# 2005,

now i have added a file in the resource properties of my applicaion,

i want to me able to extract the file from the resource to a desternation.

has anyone got any ideas on this

thanks



Re: Visual C# General extract resource file in c#

TilakGopi

Hi,

See

http://www.c-sharpcorner.com/UploadFile/casperboekhoudt/CreatingandusingResources11282005051810AM/CreatingandusingResources.aspx

This will help u definitely.

Thans & Best Regards,

Ch.T.Gopi Kumar.






Re: Visual C# General extract resource file in c#

Philly

thanks i;ll have a look at that now



Re: Visual C# General extract resource file in c#

Philly

ok i still couldnt make sence of that, im a newbie at c# Smile

can anyone give me a more simple example,

the file is called dmc2 in the files section and i want to extract it to applicaion.startuppath + "\\dmc";

thanks in advise

Phil





Re: Visual C# General extract resource file in c#

Saar_D

well i can tell you how i did it but i am quite sure there is a better way.
any how

using System.Reflection;
using System.IO;

Assembly Assemb = Assembly.GetExecutingAssembly();
Stream stream = Assemb.GetManifestResourceStream("NameOfNameSpace.Resources.NameOfFileInTheResource");
FileStream fs = new FileStream("SomeFile");
StreamReader Reader = new StreamReader(stream);
StreamWriter Writer = new StreamWriter(fs);

now if its a small text i would use Writer.write(Reader.ReadToEnd());
if it anything else i would use

byte [] save = new byte[500];
while(Reader.Read() != null)
{
Writer.write(Reader.Read(save,startindex,end));
}








Re: Visual C# General extract resource file in c#

Figo Fei - MSFT

Hi,

System.IO.File.Copy can copy between some specific path file to another.

The resource are in the resources folder.

Thanks






Re: Visual C# General extract resource file in c#

Matthew Watson

This is an internal (embedded) resource

This is the easiest way:

First add the file to your resource:

(1) In Solution Explorer, go to Properties/Resources.resx and double click it.
(2) Click the "Add Resource" button and browse-to and add the file.

Then look at "Resources.Designer.cs". There will be a property for the file that you just added. If it is a binary file, it will return a byte array. If it is a text file, it will return a string. Etc etc.

You just need to call the property to get the data, and then write that data to the destination file as required (using a StreamWriter or whatever).