I have created c# windows application for calender. When i have created the setup file and after execution of it on other machine, i did not able to get the all images on application.
code is as under.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.Globalization;
using System.Collections;
namespace calender
{
public partial class Form2 : Form
{
ArrayList alist = new ArrayList();
int i = 0;
int filelength = 0;
System.Windows.Forms.DateTimePicker month;
public Form2()
{
InitializeComponent();
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
//pass current month in string
string dm = DateTime.Now.Month.ToString();
//declare condition of display month wise image
if (dm =="1")
{
pictureBox1.ImageLocation ="";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "2")
{
pictureBox1.ImageLocation = "BFeb.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "3")
{
pictureBox1.ImageLocation = "CMar.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "4")
{
pictureBox1.ImageLocation = "DApril.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "5")
{
pictureBox1.ImageLocation = "EMay.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "6")
{
pictureBox1.ImageLocation = "FJune.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "7")
{
pictureBox1.ImageLocation = "GJully.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "8")
{
pictureBox1.ImageLocation = "HAug.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "9")
{
pictureBox1.ImageLocation = "ISep.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "10")
{
pictureBox1.ImageLocation = "JOct.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "11")
{
pictureBox1.ImageLocation = "KNov.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
else if (dm == "12")
{
pictureBox1.ImageLocation = @"E:\Khadse\calender\calender\Image\LDec.png";
pictureBox1.Location = new Point(0, 0);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Size = new Size(300, 300);
}
}
private int _pictureIndex = 0;
private void button1_Click(object sender, EventArgs e)
{
}
private void Form2_Load(object sender, EventArgs e)
{
System.IO.DirectoryInfo inputDir = new System.IO.DirectoryInfo(@"E:\Khadse\calender\calender\Image"); //Source image folder path
try
{
if ((inputDir.Exists))
{
//Get Each files
System.IO.FileInfo file = null;
foreach (System.IO.FileInfo eachfile in inputDir.GetFiles())
{
file = eachfile;
if (file.Extension == ".png")
{
alist.Add(file.FullName); //Add it in array list
filelength = filelength + 1;
}
}
pictureBox1.Image = Image.FromFile(alist[0].ToString()); //Display intially first image in picture box as sero index file path
i = 0;
}
}
catch (Exception ex)
{
}
}
//if user click Previous then show lower previous arraylist value image
private void btnprev_Click(object sender, EventArgs e)
{
if (i - 1 >= 0)
{
pictureBox1.Image = Image.FromFile(alist[i - 1].ToString());
i = i - 1;
}
}
//if user click "Next" then show next arraylist value image
private void btnnext_Click(object sender, EventArgs e)
{
if (i + 1 < filelength)
{
pictureBox1.Image = Image.FromFile(alist[i + 1].ToString());
i = i + 1;
}
}
//dragable window code
int mouseX = 0, mouseY = 0;
bool mouseDown;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
mouseDown = true;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (mouseDown)
{
mouseX = MousePosition.X - 200;
mouseY = MousePosition.Y - 20;
this.SetDesktopLocation(mouseX, mouseY);
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
mouseDown = false;
}
}
}