首先读取当前路径,之后提取出父路径。。
string currentPath = Directory.GetCurrentDirectory();
DirectoryInfo dirInfo = Directory.GetParent(currentPath);
currentPath = dirInfo.ToString();
dirInfo = Directory.GetParent(currentPath);
currentPath = dirInfo.ToString() + @"\images\sky.jpg";以上,用到了Directory和DirectoryInfo,需要包含以下语句:
using System;
using System.IO;
本文介绍了一种使用 C# 的 Directory 和 DirectoryInfo 类来获取当前文件所在目录的父目录的方法,并展示了如何将路径设置为指定的图片文件。
554

被折叠的 条评论
为什么被折叠?



