Solved

C# Find icon fle

Posted on 2011-03-12
18
548 Views
Last Modified: 2013-12-17
Hi,

I enherit a program whose title bar has an icon in the left. I open the file from visual studio.
I open the form, and its property I see the icon picture but I could not find the file of this icon.
Do you know how?

Thanks,
JT
0
Comment
Question by:jtran007
  • 7
  • 7
  • 3
  • +1
18 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118004
It's probably an embedded resource.  Right-click your project, choose Properties, go to the Resources tab and check the Icons list.  Or, open the .resx file that corresponds to your form.  You can also extract it programmatically with a couple lines of code in the form's Load event:

using (System.IO.FileStream iconStream = new System.IO.FileStream("C:\\theIcon.ico", System.IO.FileMode.Create))
{
    this.Icon.Save(iconStream);
}

Open in new window

0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 35118064
Hi jtran007;

You state, "I could not find the file of this icon.", the reason is that the Icon when it was added it was imported as a copy into the forms resource file and is compiled into the program. In Solution Explorer click on Show All Files then then expand the form in question and open the file FormX.Designer.cs and find the section of code :

//
// Form1
//

You will find a line of code like this:

this.Icon = ( ( System.Drawing.Icon ) ( resources.GetObject( "$this.Icon" ) ) );

This line of code gets the icon info from the forms compiled resource data.

So to answer your question it is no longer on the file system but as a copy in the forms resource.

Fernando
0
 

Author Comment

by:jtran007
ID: 35118247
Hi,

I open the *.resx, and check the form1.cs but I could not anthing that both of you suggest.

Regards,
JT
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118273
It would either be a project resource (right-click project -> Properties -> Resources -> Icons), in a resource file (a .resx file) which may or may not be the form's .resx (i.e. there could be a separate .resx file that's linked), or part of another project (another .exe or .dll).  I suppose it could be drawn at run-time in code, but I think that'd be highly unlikely.

If you can't find it and just want to get the .ico file, put the code snippet I suggested above in the form's load event:
using (System.IO.FileStream iconStream = new System.IO.FileStream("C:\\theIcon.ico", System.IO.FileMode.Create))
{
    this.Icon.Save(iconStream);
}

Open in new window

0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118277
Forgot pictures...
VS-Resources.png
Form-RESX.png
0
 

Author Comment

by:jtran007
ID: 35118382
Hi,

I open the project property with resources setting, I could not find the icon file in tab Icon.

Also if I include your code, I got the error from this module:

      protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

Regards,
JT
0
 

Author Comment

by:jtran007
ID: 35118399
Hi,

The error message is:
Error      4      'UpdatePanel.MainUpdate.Dispose(bool)': no suitable method found to override      C:\Users\tran\Documents\Visual Studio 2010\Projects\Tyco\updatepanel\updatepanel\UpdatePanel\MainUpdate.Designer.cs      14      33      UpdatePanel

Now I remove your code, I still receive this error which I did not in the beginning.

JT
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118401
Can you post your entire Program.cs file?
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118411
May as well throw MainUpdate.cs and MainUpdate.Designer.cs too. ;)

(You must've accidentally pasted over top of something you shouldn't have)
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:jtran007
ID: 35118423
Hi,

Designer code;

namespace UpdatePanel
{
    partial class MainUpdate
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        ///
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainUpdate));
            this.button1 = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.button2 = new System.Windows.Forms.Button();
            this.label4 = new System.Windows.Forms.Label();
            this.panel1 = new System.Windows.Forms.Panel();
            this.txtComplete = new System.Windows.Forms.TextBox();
            this.txtUploading = new System.Windows.Forms.TextBox();
            this.txtPanelCoonect = new System.Windows.Forms.TextBox();
            this.txtWarning = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button1.FlatAppearance.BorderSize = 0;
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button1.Font = new System.Drawing.Font("Arial Narrow", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.button1.Location = new System.Drawing.Point(790, 542);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(105, 27);
            this.button1.TabIndex = 2;
            this.button1.Text = "Start Update";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click_2);
            //
            // label1
            //
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label1.BackColor = System.Drawing.Color.Transparent;
            this.label1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.Navy;
            this.label1.Location = new System.Drawing.Point(342, 51);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(635, 46);
            this.label1.TabIndex = 11;
            this.label1.Text = "This utility will upgrade DSC Power 4.2 panels to v4.5.  It cannot be used to upg" +
                "rade any other versions.";
            //
            // label2
            //
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label2.BackColor = System.Drawing.Color.Transparent;
            this.label2.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.Navy;
            this.label2.Location = new System.Drawing.Point(342, 134);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(596, 79);
            this.label2.TabIndex = 11;
            this.label2.Text = resources.GetString("label2.Text");
            //
            // label3
            //
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label3.BackColor = System.Drawing.Color.Transparent;
            this.label3.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.Firebrick;
            this.label3.Location = new System.Drawing.Point(342, 280);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(596, 43);
            this.label3.TabIndex = 12;
            this.label3.Text = "Warning:  The process must complete fully.  Any interuption in the update process" +
                " may result in unrecoverable errors in the panel";
            this.label3.Click += new System.EventHandler(this.label3_Click);
            //
            // button2
            //
            this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.button2.FlatAppearance.BorderSize = 0;
            this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button2.Font = new System.Drawing.Font("Arial Narrow", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.button2.Location = new System.Drawing.Point(901, 542);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(105, 27);
            this.button2.TabIndex = 2;
            this.button2.Text = "Cancel";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // label4
            //
            this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label4.BackColor = System.Drawing.Color.Transparent;
            this.label4.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.Navy;
            this.label4.Location = new System.Drawing.Point(342, 406);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(365, 29);
            this.label4.TabIndex = 11;
            this.label4.Text = "Click [Start Update] to begin the flashing process";
            //
            // panel1
            //
            this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.panel1.Controls.Add(this.txtComplete);
            this.panel1.Controls.Add(this.txtUploading);
            this.panel1.Controls.Add(this.txtPanelCoonect);
            this.panel1.Controls.Add(this.txtWarning);
            this.panel1.Controls.Add(this.label5);
            this.panel1.Location = new System.Drawing.Point(1, 1);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(295, 568);
            this.panel1.TabIndex = 13;
            //
            // txtComplete
            //
            this.txtComplete.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.txtComplete.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtComplete.Enabled = false;
            this.txtComplete.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtComplete.Location = new System.Drawing.Point(26, 480);
            this.txtComplete.Name = "txtComplete";
            this.txtComplete.Size = new System.Drawing.Size(218, 15);
            this.txtComplete.TabIndex = 4;
            this.txtComplete.Text = "4- Completing the process";
            //
            // txtUploading
            //
            this.txtUploading.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.txtUploading.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtUploading.Enabled = false;
            this.txtUploading.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtUploading.Location = new System.Drawing.Point(26, 350);
            this.txtUploading.Name = "txtUploading";
            this.txtUploading.Size = new System.Drawing.Size(218, 15);
            this.txtUploading.TabIndex = 3;
            this.txtUploading.Text = "3- Uploading Firmware";
            //
            // txtPanelCoonect
            //
            this.txtPanelCoonect.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.txtPanelCoonect.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtPanelCoonect.Enabled = false;
            this.txtPanelCoonect.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtPanelCoonect.Location = new System.Drawing.Point(26, 220);
            this.txtPanelCoonect.Name = "txtPanelCoonect";
            this.txtPanelCoonect.Size = new System.Drawing.Size(218, 15);
            this.txtPanelCoonect.TabIndex = 2;
            this.txtPanelCoonect.Text = "2- Preparing Panel Connection";
            //
            // txtWarning
            //
            this.txtWarning.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.txtWarning.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtWarning.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtWarning.Location = new System.Drawing.Point(26, 90);
            this.txtWarning.Name = "txtWarning";
            this.txtWarning.Size = new System.Drawing.Size(218, 15);
            this.txtWarning.TabIndex = 1;
            this.txtWarning.Text = "1- Warning Notice";
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font("Arial", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.label5.Location = new System.Drawing.Point(12, 19);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(270, 19);
            this.label5.TabIndex = 0;
            this.label5.Text = "Four Stages of Updating the Panel";
            //
            // label6
            //
            this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.label6.BackColor = System.Drawing.Color.Transparent;
            this.label6.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.ForeColor = System.Drawing.Color.Navy;
            this.label6.Location = new System.Drawing.Point(341, 1);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(613, 24);
            this.label6.TabIndex = 14;
            this.label6.Text = "1- Warning Notice";
            //
            // MainUpdate
            //
            this.AcceptButton = this.button1;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.CancelButton = this.button2;
            this.ClientSize = new System.Drawing.Size(1018, 574);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "MainUpdate";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Power 4.x Updater";
            this.Load += new System.EventHandler(this.MainUpdate_Load);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox txtComplete;
        private System.Windows.Forms.TextBox txtUploading;
        private System.Windows.Forms.TextBox txtPanelCoonect;
        private System.Windows.Forms.TextBox txtWarning;
        private System.Windows.Forms.Label label6;



    }
}



cs code:

using System.Windows.Forms;
using System.Configuration;
using System.ComponentModel;
using Microsoft.VisualBasic.Devices;
using System.Drawing;
using System;
using System.Drawing.Drawing2D;
//using System.IO;

namespace UpdatePanel
{

    public partial class MainUpdate : Form
    {


        public MainUpdate()
        {
            InitializeComponent();
            this.txtWarning.Focus();

        }

        //
        // this form prepares user to go into power recycle mode
        //
        private void button1_Click_2(object sender, System.EventArgs e)
        {

            UpdateProcess up = new UpdateProcess();
            up.Icon = this.Icon;
            up.Show();
            this.Hide();

        }

        protected override void OnPaint(PaintEventArgs e)
        {
            // somehow the stupid width and/or height was 0, so we are going use Math.Max(..., 1) to get the max
            Rectangle clientRect = new Rectangle(0, 0, Math.Max(this.Width, 1), Math.Max(this.Height, 1));
            //LinearGradientBrush lgb = new LinearGradientBrush (clientRect,startColor,endColor,gradAngle,true);
            e.Graphics.FillRectangle(Brushes.White, clientRect);
            clientRect = new Rectangle(0, 0, 40, Math.Max(this.Height, 1));
            using (LinearGradientBrush lgb = new LinearGradientBrush(clientRect, Color.LightGray, Color.White, 0, true))
            {
                //Graphics g = e.Graphics;
                e.Graphics.FillRectangle(lgb, clientRect);
            }
        }

        /// <summary>
        /// close the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void MainUpdate_Load(object sender, EventArgs e)
        {
            //using (System.IO.FileStream iconStream = new System.IO.FileStream("C:\\theIcon.ico", System.IO.FileMode.Create))
            //{
            //    this.Icon.Save(iconStream);
            //}

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }
    }
}

Regards,
JT
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 35118649
Hi JT;

In your last post in the designer code class MainUpdate you find this code

            // 
            // MainUpdate
            // 
            this.AcceptButton = this.button1;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.CancelButton = this.button2;
            this.ClientSize = new System.Drawing.Size(1018, 574);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "MainUpdate";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Power 4.x Updater";
            this.Load += new System.EventHandler(this.MainUpdate_Load);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.ResumeLayout(false);

Open in new window


You will find this line of code:

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

This is where the icon is stored in the compiled code.

Fernando 
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35118859
@Fernando - I could be wrong, but I think he wants the actual icon so he can edit it, not the line of code that sets the form's Icon property.

@jtran - I copied and pasted that code exactly as you posted it (http:#a35118423 - the only change I made was to comment out the contents of button1_Click_2, since I don't have the UpdateProcess form), and I didn't receive any errors.  The error you referred to above (http:#a35118399) would suggest either you're missing the partial keyword from either MainUpdate.cs or MainUpdate.Designer.cs - or - you're not inheriting from Form in MainUpdate.cs (i.e. you have public partial class MainUpdate but it should be public partial class MainUpdate : Form.  Or possibly you're missing a using System.Windows.Forms somewhere, or missing a library reference.

As for the icon - if you override onLoad and include the snippet I posted above you can save the icon to a file somewhere:
using System.Windows.Forms;
using System.Configuration;
using System.ComponentModel;
using Microsoft.VisualBasic.Devices;
using System.Drawing;
using System;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication1
{
    public partial class MainUpdate : Form
    {
        public MainUpdate()
        {
            InitializeComponent();
            this.txtWarning.Focus();

        }

                //
                // Temporary code to extract icon
                //
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			string iconPath = "C:\\MainUpdate.ico";

			using (System.IO.FileStream iconStream = new System.IO.FileStream(iconPath, System.IO.FileMode.Create))
				this.Icon.Save(iconStream);
		}
                //
                // End of temporary icon code
                //

        //
        // this form prepares user to go into power recycle mode
        //
        private void button1_Click_2(object sender, System.EventArgs e)
        {

            //UpdateProcess up = new UpdateProcess();
            //up.Icon = this.Icon;
            //up.Show();
            this.Hide();

        }

        protected override void OnPaint(PaintEventArgs e)
        {
            // somehow the stupid width and/or height was 0, so we are going use Math.Max(..., 1) to get the max
            Rectangle clientRect = new Rectangle(0, 0, Math.Max(this.Width, 1), Math.Max(this.Height, 1));
            //LinearGradientBrush lgb = new LinearGradientBrush (clientRect,startColor,endColor,gradAngle,true);
            e.Graphics.FillRectangle(Brushes.White, clientRect);
            clientRect = new Rectangle(0, 0, 40, Math.Max(this.Height, 1));
            using (LinearGradientBrush lgb = new LinearGradientBrush(clientRect, Color.LightGray, Color.White, 0, true))
            {
                //Graphics g = e.Graphics;
                e.Graphics.FillRectangle(lgb, clientRect);
            }
        }

        /// <summary>
        /// close the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void MainUpdate_Load(object sender, EventArgs e)
        {
            //using (System.IO.FileStream iconStream = new System.IO.FileStream("C:\\theIcon.ico", System.IO.FileMode.Create))
            //{
            //    this.Icon.Save(iconStream);
            //} 

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }
    }
}

Open in new window


Also, when posting code it's much easier for us to read if you put it inside Expert Exchange's [ code ] - [ /code ] blocks (no spaces between the brackets and text, just did that so it wouldn't render as a code block).
0
 

Author Comment

by:jtran007
ID: 35118927
Hi tgerbert,

Please forget about the error. I just copy my original program, and compile. It's ok.

You are right. I just need the icon file no the line of code.

I could not find the icon file from both of your suggestions.

Regards,
JT
0
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 200 total points
ID: 35118971
Incidentally, as Fernando pointed out, it's being set from a resource, which means you should find it in MainUpdate.resx.  Double click MainUpdate.resx, use the drop-down selector in the top-left corner to switch to the Icons view.

You can also just temporarily stick some code in the form to save the icon to a file on your C: drive.

Did you see the modified MainUpdate.cs I posted above (http:#a35118859)?  Implement that code, run your program, take the code out.  As the code is, it saves the icon the C:\MainUpdate.ico, but you can change iconPath variable on line 27 if you want to save it somewhere else.
tgerbert-425904.flv
0
 

Author Comment

by:jtran007
ID: 35119012
Hi,

I did exactly as you said: "Double click MainUpdate.resx, use the drop-down selector in the top-left corner to switch to the Icons view." Unfortunately I could not find any icon file in this folder.

I'll try your code again.

Thanks,
JT

0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 50 total points
ID: 35119519
Hi JT;

Is it possible that you can zip up the project and upload it the EE Stuff web site. if you can follow the following instructions.

To upload a file in zip format to the Experts Exchange Stuff web site at http://www.ee-stuff.com follow these steps:

1.  Zip the files or project to be uploaded
2.  The go to http://www.ee-stuff.com
3.  If you are prompted to log in use the same username and password you use on the main site here
4.  At the top of the page click on "Expert Area" tab
5.  Then click on "Upload a new file" link
6.  Follow the instructions on the page
7.  After a successful upload post the link of the file in the question.

Fernando
0
 
LVL 5

Expert Comment

by:MedievalWarrior
ID: 35121365
If you find the resource location and want to save that to disk then you'll have to write the raw bytes contained in the resource and not use the Icon.Save method. There is no output encoder for Icon Class so you will end up with a 16 bit icon file if you use Icon.Save method. Instead read the bytes of the icon and write them into file.
0
 

Author Closing Comment

by:jtran007
ID: 35122043
Hi,

I found the icon file as you(tgerbert) suggested.
Thanks,
JT
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now