您的位置:首页 > 运维架构 > 网站架构

C#获取dll路径的方法(适合B/S和C/S架构)

2011-05-04 10:09 225 查看
private string GetAssemblyPath()
        {
            string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            codeBase = codeBase.Substring(8, _CodeBase.Length - 8);    // 8是 file:// 的长度

            string[] arrSection = codeBase.Split(new char[] { '/' });

            string folderPath = "";
            for (int i = 0; i < arrSection.Length - 1; i++)
            {
                folderPath += arrSection[i] + "/";
            }

            return folderPath;
        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dll c# string file