zoukankan      html  css  js  c++  java
  • WinCE中获取根目录的几种方式(C#)

    由于在WinCE中不支持相对路径,同时很多在Winform中可以使用的方法在Wince中都不可用。

    今天用到,就上网查找了下。有这么几个方式获取根目录的文件

    string root = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\Configure.xml";

    或者

    String CodePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
    CodePath = CodePath.Substring(0, CodePath.LastIndexOf(@"\"));
    string filename = CodePath + "\\Configure.xml";

    或者使用API

    [DllImport("Coredll.dll", EntryPoint = "GetModuleFileName")]
    private static extern uint GetModuleFileName(IntPtr hModule, [Out] StringBuilder lpszFileName, int nSize);
    StringBuilder root = new StringBuilder(256);
    GetModuleFileName(IntPtr.Zero, root, 256);

    本来GetModuleFileName函数是在"Kernel32.dll"中的,但是在WINCE中,"Coredll.dll"对应了"Kernel32.dll"和"User32.dll"这两个文件了,所以将"Kernel32.dll"换成"Coredll.dll"。

  • 相关阅读:
    web测试--安全性
    web测试--链接测试
    web测试--兼容性
    web测试--界面和易用性
    web测试--返回键、回车键、刷新键
    web测试--查询结果
    列表标签代码解析
    备份
    java格式化时间
    js往div里添加table
  • 原文地址:https://www.cnblogs.com/yabbi/p/3066515.html
Copyright © 2011-2022 走看看