C#获取当前路径的方法
//获取包含清单的已加载文件的路径或 UNC 位置。
public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location;
//result: X:\xxx\xxx\xxx.dll (.dll文件所在的目录+.dll文件名)
//获取当前进程的完整路径,包含文件名(进程名)。
string str = this.GetType ( ).Assembly.Location;
//result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
string str = System.Diagnostics.Process.GetCurrentProcess ( ).MainModule.FileName;
//result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
string str = System.Environment.CurrentDirectory;
//result: X:\xxx\xxx (.exe文件所在的目录)
//获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。
string str = System.AppDomain.CurrentDomain.BaseDirectory;
//result: X:\xxx\xxx\ (.exe文件所在的目录+"\")
//获取和设置包含该应用程序的目录的名称。
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//result: X:\xxx\xxx\ (.exe文件所在的目录+"\")
//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
string str = System.Windows.Forms.Application.StartupPath;
//result: X:\xxx\xxx (.exe文件所在的目录)
//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
string str = System.Windows.Forms.Application.ExecutablePath;
//result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)
//获取应用程序的当前工作目录(不可靠)。
string str = System.IO.Directory.GetCurrentDirectory ( );
//result: X:\xxx\xxx (.exe文件所在的目录)
//在系统服务中最好用这个方式去取路径
string stmp = Assembly.GetExecutingAssembly ( ).Location;
stmp = stmp.Substring ( 0 , stmp.LastIndexOf ( '\\' ) );//删除文件名
if ( pathType == 1 )
return stmp + @"\inputLog.xml";
else if ( pathType == 2 )
return stmp + @"\MiddleDB.xml";
else
return stmp + @"\AppNo.xml";
using System.IO;
string path = "d:asdfasdf.bmp";
string fileNam
相关文档:
接上一篇
删除原genre属性,删除leixing=love的所有结点。
1 原xml文件 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="love" ISBN="1234123">
<title>who am i </title>
<author>who</aut ......
1、C/C++程序员请注意,不能在case语句不为空时“向下执行”。
2、值类型和引用类型之间的区别:C#的基本类型(int,char等)都是值类型,是在栈中创建的。而对象是引用类型,创建于堆中,需要使用关键字new。
3、在C#中通过实例访问静态方法或成员变量是不合法的,会生成编译器错误。但是我们可以通过声明他 ......
记取记录集
create procedure getArticle
as
select * from Article_Content
GO
asp.net 调用方法
SqlConnection Conn = new SqlConnection();
Conn.ConnectionString = Data.Connstr();
Conn.Open();
......
命名空间: MapInfo.Data
MapInfo.Data 命名空间包含了实现 MapInfo .NET 数据提供方的类和接口。 对 MapInfo 数据的访问有两种形式:作为使用 SQL 与数据交互的 ADO.NET 数据提供程序和作为使用类与数据交互的 Feature 对象。 MapIn ......
冒泡排序
using System;
class Program
{
public static void Main()
{
int[] a = new int[10];
Random rand = new Random();
for (int i = 0; i < 10; i++)
{
a[i] = rand.Next(10);//生成随机数给数组赋值
}
for (int i = 0; i < ......