如何给出绝对路径? [英] how to give the absolute path ?

查看:99
本文介绍了如何给出绝对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,





i已经开发了一个代码,该代码可以重新获取图像,同时执行图像被重新执行并执行,但是当我创建一个安装文件并安装时我没有显示图像。

得到错误这个文件不存在。



请建议我,如何给出这个项目的绝对路径。

提前感谢。





hello friends,


i have developed a code which is given a image retriving , in this while execution image are retrived and executed , but when i created a setup file and installs i does'nt shows the image .
getting error this file is not exist.

please suggest me , how to give the absolute path in this project.
thanks in advance.


string path = (@"../PatientsPhotos/" + this.patientid + ".jpg");



               if (File.Exists(path))
               {
                   ImageSource imageSource = (ImageSource)imgConv.ConvertFromString(path);
                   imgVideo.Source = imageSource;
               }
               else
               {

                   file doesn't exist;
               }

推荐答案

要将虚拟路径转换为绝对(物理)路径,您需要使用 MapPath方法 [ ^ ]
To convert virtual path to absolute (physical) path you need to use MapPath method[^]


尝试:

Try:
string path = @"../PatientsPhotos/" + this.patientid + ".jpg";
string fullPath = Path.GetFullPath(path);


这篇关于如何给出绝对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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