创建包含app数据+ PictureBox问题的.exe文件 [英] Creating .exe file containing app data + PictureBox problem

查看:58
本文介绍了创建包含app数据+ PictureBox问题的.exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



我的Winforms应用程序有两个问题。



在我的应用程序中我正在从包含1000张照片的文件夹中读取。



1.每次我运行我的应用程序时,我都会编程来阅读存储在特定文件夹中的照片并将它们放入在DB(字典(字符串,图像))中,使用:



Hello Everyone,

I have two problems with my Winforms application.

In my app im reading from a folder that contains 1000 photos.

1. Each time Im running my app, I programed it to read the photos stored in a specific folder and put them in a DB (Dictionary(string,image)), using:

dI = new DirectoryInfo(@"C:\Users\Me\Desktop\Photos");
fileInfos = dI.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in fileInfos)
{
    DB.Add(Path.GetFileNameWithoutExtension(fi.FullName), Image.FromFile(fi.FullName));
}





但是当我尝试使用以下方式将照片放入pictureBox时:



but when im trying to place a photo in a pictureBox using:

pictureBox4.BackgroundImage =  DB["PhotoName"];





它什么也没有显示,空白。< br $> b $ b

这是一个缺点,原因,



2.我想在其他电脑上使用这个应用程序仅使用存储在..\bin\debug \

中的.exe文件,而不是每次更改照片存储的路径...



那么,如何为已经包含所有照片的应用创建.exe文件?不用担心他们? (问题没有''2)



并且,如何确保照片显示(问题没有''1)



谢谢大家!



It shows nothing, blank.

that''s a drawback, CAUSE,

2. I want to use this app in other computers using only the .exe file that stored in the ..\bin\debug\
without each time changing the path the photos are stored...

So, how do I create an .exe file for my app that already has all the photos? without worring about them? (problem no'' 2)

And, how to make sure the photos are shown (problem no'' 1)

Thank you all!

推荐答案

可能会显示图像 - 当我尝试你的代码时肯定会在这里。

但是 - 你确定你想在BackgroundImage中使用它吗?因为如果你在Image属性中显示不同的图像,你可能不会看到你的背景...你是否尝试过设置图像属性?





顺便说一句:如果你总是想要相同的图像,我会将它们作为嵌入式资源构建到你的EXE中,而不是将它们作为单独的文件加载。
The chances are that the image is being shown - it certainly is here when I try your code.
But - are you sure you want it in the BackgroundImage? Because if you show a different image in the Image property, you probably won''t see your background one...Have you tried setting teh Image property instead?


BTW: if you always want the same images, I would build them in as embedded resources to your EXE instead of loading them as separate files.


RoyDoron写道:
RoyDoron wrote:

如何为已经拥有所有照片的应用创建.exe文件?不用担心他们? (问题没有''2)

how do I create an .exe file for my app that already has all the photos? without worring about them? (problem no'' 2)





您可以使用资源。 添加和编辑资源 [ ^ ]非常简单;)< br $> b $ b

Embeding项目中的图像资源 [ ^ ]

代码:检索作为嵌入式资源的图像(Visual C#) [ ^ ]



You can use resources. Adding and Editing resources[^] is very easy ;)

Embeding Image Resources in a project[^]
Code: Retrieving an Image that is an Embedded Resource (Visual C#)[^]


这篇关于创建包含app数据+ PictureBox问题的.exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆