C#获取当前路径,获取当前路径的上一层路径
C#获取当前路径的方法如下:
(1)string path1 = System.Environment.CurrentDirectory;
//C:\...\bin\Debug
-获取和设置当前工作目录(该进程从中启动的目录)的完全限定目录。
(2)string path2 = System.IO.Directory.GetCurrentDirectory();
//C:\...\bin\Debug
-获取应用程序的当前工作目录。网上说这个方法得到的不一定是程序从中启动的目录,我试的和(1)的结果一样,证明有时得到的还是程序从中启动的目录。
(3)string path3 = System.Windows.Forms.Application.StartupPath;
//C:\...\bin\Debug
-获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
(4)string path4 = System.AppDomain.CurrentDomain.BaseDirectory;
//C:\...\bin\Debug\
-获取基目录,它由程序集冲突解决程序用来探测程序集。
(5)string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//C:\...\bin\Debug\
-获取或设置包含该应用程序的目录的名称。
(6)string path6 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
//C:\...\bin\Debug\WindowsFormsApplication1.vshost.exe
-获取模块的完整路径。
()7string path7 = System.Windows.Forms.Application.ExecutablePath;
//C:\...\bin\Debug\WindowsFormsApplication1.EXE
-获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
当前路径与相对路径的合并:
string path8 = System.IO.Path.GetFullPath(System.IO.Path.Combine(path1, @"..\..\obj\x86\Debug"));
string[] array = System.IO.Directory.GetFiles(path8);
C#获取当前路径,获取当前路径的上一层路径的更多相关文章
- C# 如何获取当前应用程序的上一级路径
Server.MapPath 的使用方法 用法: 1.Server.MapPath ("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Serve ...
- python 获取当前,上级,上上级路径
import os print '***获取当前目录***' print os.getcwd() print os.path.abspath(os.path.dirname(__file__)) pr ...
- C#获取文件的当前路径
C#获取文件的当前路径 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2.Syst ...
- 使用html5 FileReader获取图片,并异步上传到服务器(不使用iframe)
使用html5 FileReader获取图片,并异步上传到服务器(不使用iframe) 原理: 1.使用FileReader 读取图片的base64编码 2.使用ajax,把图片的base64编码 ...
- excel小技巧-用于测试用例的编号栏:“获取当前单元格的上一格的值+1”=INDIRECT(ADDRESS(ROW()-1,COLUMN()))+1
编写用例的时候使用,经常修改用例的时候会需要增加.删除.修改条目,如果用下拉更新数值的方式会很麻烦. 1.使用ctrl下拉,增删移动用例的时候,需要每次都去拉,万一列表比较长,会很麻烦 2.使用ROW ...
- django设置并获取cookie/session,文件上传,ajax接收文件,post/get请求及跨域请求等的方法
django设置并获取cookie/session,文件上传,ajax接收文件等的方法: views.py文件: from django.shortcuts import render,HttpRes ...
- git获取别人远程dev分支上的代码
我们在使用 git clone xxx.git 下载代码的时候,获取到的只是 master上的代码 假入有个 dev 分支我们想获取上面的代码怎么办! #下载dev分支上的代码并切换到dev分支 g ...
- 使用html5 FileReader获取图片,并异步上传到server(不使用iframe)
使用html5 FileReader获取图片,并异步上传到server(不使用iframe) 原理: 1.使用FileReader 读取图片的base64编码 2.使用ajax.把图片的base64编 ...
- 如何获取已经安装到苹果手机上的App信息
//如何获取已经安装到苹果手机上的App信息? Is it possible to get the information (app icon, app name, app location) abo ...
随机推荐
- powershell学习
PowerShell 调试器 在开始运行处,输入powershell ISE回车即可 PowerShell 与操作系统版本 powershell在windows server 2008上自带,但最好在 ...
- 用BigDecimal类实现Fibonacci算法
Fibonacci(N)=Fibonacii(N-1)+Fibonacci(N-2) 其中 Fibonacci(0)=0;Fibonacci(1)=1 用循环或则递归实现Fibonacci算法很简单, ...
- poj 1144 Network【双连通分量求割点总数】
Network Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11042 Accepted: 5100 Descript ...
- 联通超级战舰W910 Root 后不能 上网 解决方案
联通版的超级战舰w910root后不能上网,一下是root方法: 超级战舰W910 Root方法: 电脑上安装“刷机精灵”(http://www.shuame.com/ ),在手机“菜单”——“系统设 ...
- apache安装php7过程中遇到到段错误
1.假如apache的配置文件httpd.conf同时加载libphp5.so和libphp7.so 2.如图所示,modules下同时存在libphp5.so/libphp7.so 3.启动apac ...
- jQuery进行图片预先加载
/** **将图片加载到内存中,在页面任何位置引用的时候,直接从缓存中读取,提升用户的体验,提高网站的流畅度.** **/ <!DOCTYPE html PUBLIC "-//W3C/ ...
- POJ 2728 Desert King
Description David the Great has just become the king of a desert country. To win the respect of his ...
- Android Developers:拖动和缩放
这个课程描述了如何使用手势来拖拽和缩放屏幕的对象,使用onTouchEvent()方法来获取触摸事件.这里是这节课程使用的源代码. 拖动一个对象 ——————————————————————————— ...
- 在Java中如何用String类中的indexof方法得到一个词的出现频率
public class Test{ public static void main(String[] args) { String s="hello jack hello look me ...
- Android之发送短信和接收验证码
最近项目需求需要发送短信和接收验证码并将验证码显示在输入框中 以下是我的记录 前提---权限 <uses-permission android:name="andro ...