Click here to Skip to main content
15,923,083 members
Home / Discussions / C#
   

C#

 
QuestionHow I start with Crystal Report Programaticlly? Pin
magdyeltahaan11-Apr-09 3:40
magdyeltahaan11-Apr-09 3:40 
AnswerRe: How I start with Crystal Report Programaticlly? Pin
0x3c011-Apr-09 3:43
0x3c011-Apr-09 3:43 
QuestionLoad a big file to a textbox Pin
CheatCat11-Apr-09 3:23
CheatCat11-Apr-09 3:23 
AnswerRe: Load a big file to a textbox Pin
0x3c011-Apr-09 3:34
0x3c011-Apr-09 3:34 
GeneralRe: Load a big file to a textbox Pin
CheatCat11-Apr-09 3:54
CheatCat11-Apr-09 3:54 
GeneralRe: Load a big file to a textbox Pin
0x3c011-Apr-09 4:22
0x3c011-Apr-09 4:22 
GeneralRe: Load a big file to a textbox Pin
Luc 64801111-Apr-09 4:37
Luc 64801111-Apr-09 4:37 
Questiongif Image Pin
Karmendra Suthar11-Apr-09 3:01
Karmendra Suthar11-Apr-09 3:01 
Hi,
I embedded some files in the assembly, html(text) images(gif, jpg, png).
What i want to do is extract all the files to a tmp directory.

I had SUCCESS in getting all the files to tmp directory. I open the text files..PERFECT. but images are not right, it says corrupt. How do I get the images extracted correctly from embedded resource and save it to disk.

Following is my piece of code.

private void button1_Click(object sender, EventArgs e)
        {
            Assembly _assembly;
            Stream _imageStream;
            StreamReader _StreamReader;

            StreamWriter _StreamWriter;
            string dirpath = Application.StartupPath + "\\help";
            string[] resourceNames = this.GetType().Assembly.GetManifestResourceNames();
            foreach (string resourceName in resourceNames)
            {
                //get resource if it is help
                if (resourceName.Contains(".help"))
                {
                    MessageBox.Show(resourceName);
                    try
                    {
                        if (!Directory.Exists(dirpath))
                        {
                            DirectoryInfo di = Directory.CreateDirectory(dirpath);
                            di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
                            di.CreateSubdirectory("images");
                        }
                        string filename = Application.StartupPath + "\\help\\";

                        //if image, it should save in image folder
                        if (resourceName.Contains(".images")) filename = filename + "images\\";
                        //get the filename and append it to the filename
                        string[] filenamearray = resourceName.Split('.');
                        int length = filenamearray.Length;
                        filename = filename + filenamearray[length - 2] + "." + filenamearray[length-1];

                        string read = null;

                        _assembly = Assembly.GetExecutingAssembly();
                        _StreamReader = new StreamReader(_assembly.GetManifestResourceStream(resourceName));
                        _StreamWriter = new StreamWriter(filename);

                        while ((read = _StreamReader.ReadLine()) != null)
                        {
                            _StreamWriter.WriteLine(read);
                        }
                        _StreamWriter.Close();
                        _StreamReader.Close();
                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }


Thanks a lot for you precious time and knowledge,

Regards,
Karmendra
AnswerRe: gif Image Pin
Luc 64801111-Apr-09 3:18
Luc 64801111-Apr-09 3:18 
GeneralRe: gif Image Pin
Karmendra Suthar11-Apr-09 3:59
Karmendra Suthar11-Apr-09 3:59 
QuestionCan a control have multi parents? Pin
Duong Tien Nam11-Apr-09 1:46
Duong Tien Nam11-Apr-09 1:46 
AnswerRe: Can a control have multi parents? Pin
Luc 64801111-Apr-09 3:14
Luc 64801111-Apr-09 3:14 
GeneralRe: Can a control have multi parents? Pin
Duong Tien Nam12-Apr-09 2:39
Duong Tien Nam12-Apr-09 2:39 
AnswerRe: Can a control have multi parents? Pin
Dave Kreskowiak11-Apr-09 7:08
mveDave Kreskowiak11-Apr-09 7:08 
QuestionMultiple Radio buttons In A Form Pin
Ravindra Bisen10-Apr-09 23:31
Ravindra Bisen10-Apr-09 23:31 
AnswerRe: Multiple Radio buttons In A Form Pin
Eddy Vluggen10-Apr-09 23:58
professionalEddy Vluggen10-Apr-09 23:58 
GeneralRe: Multiple Radio buttons In A Form Pin
Ravindra Bisen11-Apr-09 1:38
Ravindra Bisen11-Apr-09 1:38 
GeneralRe: Multiple Radio buttons In A Form Pin
Eddy Vluggen11-Apr-09 6:47
professionalEddy Vluggen11-Apr-09 6:47 
AnswerRe: Multiple Radio buttons In A Form Pin
Nagy Vilmos11-Apr-09 0:24
professionalNagy Vilmos11-Apr-09 0:24 
AnswerRe: Multiple Radio buttons In A Form Pin
Luc 64801111-Apr-09 0:25
Luc 64801111-Apr-09 0:25 
GeneralRe: Multiple Radio buttons In A Form Pin
0x3c011-Apr-09 1:16
0x3c011-Apr-09 1:16 
AnswerRe: Multiple Radio buttons In A Form Pin
Yusuf11-Apr-09 1:45
Yusuf11-Apr-09 1:45 
Questionneed help in modifying some parts of he Cosmos code Pin
john231310-Apr-09 23:23
john231310-Apr-09 23:23 
AnswerRe: need help in modifying some parts of he Cosmos code Pin
Nagy Vilmos11-Apr-09 0:16
professionalNagy Vilmos11-Apr-09 0:16 
AnswerRe: need help in modifying some parts of he Cosmos code Pin
0x3c011-Apr-09 0:33
0x3c011-Apr-09 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.