如何找到图像的绝对路径 [英] how to find absolute path of image

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

问题描述

我正在用c#3.5开发项目.

我在项目内部创建文件夹名称(图像).
我想在c#3.5中找到图像文件夹的绝对路径,就像可用的asp.net server.mappath()方法一样.


请帮助我

I''m developing project in c# 3.5.

I create the folder name (image) inside the project.
I want to find absolute path of image folder in c#3.5 like in asp.net server.mappath() method available.


Please help me

推荐答案

如果您使用Windows应用程序,则可以执行此操作.
您也可以在ASP.NET中的服务器端文件上执行此操作,但不能仅使用消息框进行操作.

If you do a windows app you can do this.
You can do this on your serverside files in ASP.NET as well, only not with a messagebox.

//Get the Image folder from your projekt.
System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo("Image");
            MessageBox.Show(DI.FullName);



这样,您便可以在代码中随意使用该文件夹.
您可以看到创建时间和Lastaccess等.



With this you got power to use the folder as you want in code.
You can see creation time and Lastaccess and so on.


说,您的图像文件夹路径为"\image"(文件夹"image"位于Web应用程序根文件夹中)

然后,找到如下所示的绝对物理路径:

Say, your image folder path is "\image" (Folder "image" is just inside the web application root folder)

Then, find the absolute physical path as follows :

string filePath = Server.MapPath("~/image");


string path = System.Reflection.Assembly.GetExecutingAssembly().Location;



这将为您提供exe所在的确切路径.通常,在部署时,映像文件夹将与exe包含在同一目录中



This will give you the exact path where the exe is located. On deploying usually the image folder will be included in the same directory as the exe


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

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