最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#的path.GetFullPath 獲取上級目錄實(shí)現(xiàn)方法

 更新時間:2014年10月28日 10:15:30   投稿:shichen2014  
這篇文章主要介紹了C#的path.GetFullPath 獲取上級目錄實(shí)現(xiàn)方法,包含了具體的C#實(shí)現(xiàn)方法以及ASP.net與ASP等的方法對比,非常具有實(shí)用價值,需要的朋友可以參考下

本文實(shí)例講述了C#的path.GetFullPath 獲取上級目錄實(shí)現(xiàn)方法,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
string path = new directoryinfo("../").fullname;//當(dāng)前應(yīng)用程序路徑的上級目錄

獲取當(dāng)前目錄可以使用
復(fù)制代碼 代碼如下:
appdomain.currentdomain.basedirectory

獲取當(dāng)前目錄的上級目錄
復(fù)制代碼 代碼如下:
path.getfullpath("..")

具體代碼如下:

復(fù)制代碼 代碼如下:
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.io;
namespace pathtest
{
class program
{
static void main(string[] args)
{
//使用appdomain獲取當(dāng)前應(yīng)用程序集的執(zhí)行目錄
string dir = appdomain.currentdomain.basedirectory;
string info = string.format("appdomain方法獲取當(dāng)前程序集目錄:{0}", dir);
console.writeline(info);
//使用path獲取當(dāng)前應(yīng)用程序集的執(zhí)行的上級目錄
dir = path.getfullpath("..");
info = string.format("path方法獲取當(dāng)前程序集上級目錄:{0}", dir); (www.fzitv.net)
console.writeline(info);
//使用path獲取當(dāng)前應(yīng)用程序集的執(zhí)行目錄的上級的上級目錄
dir = path.getfullpath(@"....");
info = string.format("path方法獲取當(dāng)前程序集目錄的級的上級目錄:{0}", dir);
console.writeline(info);
//使用path獲取當(dāng)前應(yīng)用程序集的執(zhí)行目錄的上級目錄
dir = path.getfullpath(@"......");
info = string.format("path方法獲取當(dāng)前程序集目錄的上級目錄的上級目錄:{0}", dir);
console.writeline(info);
//在當(dāng)前程序集目錄中添加指定目錄
dir = path.getfullpath(@"io");
info = string.format("在當(dāng)前程序集目錄中添加指定目錄:{0}", dir);
console.writeline(info);
console.read();
}
}
}

winform比較復(fù)雜,我只知道environment.currentdirectory是當(dāng)前exe的路徑,你要得到上一級的再用這個路徑算。
asp就比.net簡單了,直接../就行了
如果是asp.net直接用server.mappath("~/bg/")就可以了。

希望本文所述對大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

兴宁市| 图们市| 祁连县| 三门县| 永宁县| 琼中| 阜城县| 平潭县| 镇原县| 绥江县| 枞阳县| 长宁县| 富平县| 平塘县| 夏邑县| 建始县| 左权县| 静安区| 本溪| 明水县| 洪雅县| 获嘉县| 宣武区| 拉萨市| 郴州市| 吉木萨尔县| 辉南县| 天津市| 定兴县| 广德县| 北安市| 德令哈市| 安西县| 高邮市| 龙门县| 临潭县| 涡阳县| 紫云| 尉氏县| 枝江市| 河南省|