C# 为其他windows计算机执行exe安装程序后未显示图像

C# 为其他windows计算机执行exe安装程序后未显示图像,c#,C#,我已经为日历创建了c#windows应用程序。 当我创建了安装文件并在其他机器上执行后,我无法获得应用程序上的所有图像 代码如下所示 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Task

我已经为日历创建了c#windows应用程序。 当我创建了安装文件并在其他机器上执行后,我无法获得应用程序上的所有图像

代码如下所示

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;
    }
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
使用System.Data.SqlClient;
使用System.IO;
利用制度全球化;
使用系统集合;
名称空间日历
{
公共部分类表单2:表单
{
ArrayList alist=新的ArrayList();
int i=0;
int filelength=0;
System.Windows.Forms.DateTimePicker月;
公共表格2()
{
初始化组件();
pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage;
//以字符串形式传递当前月份
字符串dm=DateTime.Now.Month.ToString();
//声明显示月份图像的条件
如果(dm==“1”)
{
pictureBox1.ImageLocation=“”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则如果(dm==“2”)
{
pictureBox1.ImageLocation=“BFeb.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“3”)
{
pictureBox1.ImageLocation=“CMar.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则如果(dm==“4”)
{
pictureBox1.ImageLocation=“DApril.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“5”)
{
pictureBox1.ImageLocation=“EMay.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“6”)
{
pictureBox1.ImageLocation=“FJune.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“7”)
{
pictureBox1.ImageLocation=“GJully.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“8”)
{
pictureBox1.ImageLocation=“HAug.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“9”)
{
pictureBox1.ImageLocation=“ISep.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“10”)
{
pictureBox1.ImageLocation=“JOct.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则如果(dm==“11”)
{
pictureBox1.ImageLocation=“KNov.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
否则,如果(dm==“12”)
{
pictureBox1.ImageLocation=@“E:\Khadse\calender\calender\Image\LDec.png”;
pictureBox1.位置=新点(0,0);
pictureBox1.SizeMode=PictureBoxSizeMode.Zoom;
pictureBox1.尺寸=新尺寸(300300);
}
}
私有int_pictureIndex=0;
私有无效按钮1\u单击(对象发送者,事件参数e)
{
}
私有void Form2_加载(对象发送方、事件参数e)
{
System.IO.DirectoryInfo inputDir=new System.IO.DirectoryInfo(@“E:\Khadse\calender\calender\Image”);//源映像文件夹路径
尝试
{
如果((inputDir.Exists))
{
//获取每个文件
System.IO.FileInfo file=null;
foreach(inputDir.GetFiles()中的System.IO.FileInfo每个文件)
{
文件=每个文件;
如果(文件扩展名=“.png”)
{
alist.Add(file.FullName);//将其添加到数组列表中
filelength=filelength+1;
}
}
pictureBox1.Image=Image.FromFile(alist[0].ToString());//在图片框中初始显示第一个图像作为sero索引文件路径
i=0;
}
}
捕获(例外情况除外)
{
}
}
//如果用户单击“上一个”,则显示较低的上一个arraylist值图像
私有无效btnprev_单击(对象发送者,事件参数e)
{
如果(i-1>=0)
{
pictureBox1.Image=Image.FromFile(alist[i-1].ToString());
i=i-1;
}
}
//如果用户单击“下一步”,则显示下一个arraylist值图像
private void btnnext_单击(对象发送方,事件参数e)
{
如果(i+1<文件长度)
{
pictureBox1.Image=Image.FromFile(alist[i+1].ToString());
i=i+1;
}
}
//可拖动窗口代码
int mouseX=0,mouseY=0;
布尔·穆斯敦;
私人空皮克图