使用getfullpath函数 [英] using getfullpath function
本文介绍了使用getfullpath函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序的每一种形式中,都有一个背景图像,是从后面的代码中加载的.这就是代码:
Hi,
In every form in my application, there''s a background image that is loaded from code behind. that''s the code:
me.background=system.drawing.bitmap.fromfile(system.IO.path.getfullpath("Images\someimage.jpg"))
现在,我已将openfile对话框添加到一个winform应用程序中,并且我发现它会更改我的路径(例如,由于应用程序文件位于c:/目录中,而我上载的文件位于d:/中, ).
now I''ve added openfile dialog to one of my winform application and I''ve found out that it changes my path (since the app files are in c:/ directory, and the file I uploaded is in d:/ for example).
Is there a way to avoid it?
推荐答案
如果要在特定文件夹中启动,则在显示 OpenFile 对话框时,可以使用 InitialDirectory 属性,如下所示
http://msdn.microsoft.com /en-us/library/system.windows.forms.filedialog.initialdirectory(v=vs.90).aspx [
If you want to start in a particular folder, when OpenFile dialog is displayed, you can use InitialDirectory property as shown here
http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.initialdirectory(v=vs.90).aspx[^]
If your problem is solved then you may accept and vote the solution, otherwise please post your queries
PES
尝试将代码更改为
Try to change in your code as
me.background=system.drawing.bitmap.fromfile(system.IO.path.getfullpath("~\Images\someimage.jpg"))
如果有帮助,请将其标记为您的答案
If it helps then mark this as your answer
这篇关于使用getfullpath函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文