VB.net中的文件参考 [英] File reference in VB.net

查看:80
本文介绍了VB.net中的文件参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vb.net应用程序的硬盘驱动器中的某个位置创建了对文件的引用.

I created a reference to a file at some location in the hard drive in a vb.net application.

db_optb.Image = Image.FromFile("F:\Documents and Settings\Raza\My Documents\My Pictures\quiz_pics\opt_bg_post.jpg")


程序执行正常.

但是,当我将整个项目文件夹移至另一台PC并执行该操作时,出现了文件不存在"异常.

绝对是该PC上没有该文件.

因此可以将文件放在项目中并以这样的方式引用它:将项目带到其他地方不会造成问题吗?


The program executed fine.

But when i took the whole project folder to another PC and executed it there it gave a ''File does not exist'' exception.

Definitely the file was not there in this PC.

So can place the file in the project and refer it in such a way that taking the project to any other place does not create problems?

推荐答案

将图像放入与EXE文件相同的文件夹,并使用以下命令:
Put your images in the same folder as your EXE file and use the following :
db_optb.Image = Image.FromFile("opt_bg_post.jpg")


这篇关于VB.net中的文件参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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