
获取当前目录的方法有很多,其中之一:
TCHAR szFilePath[MAX_PATH + 1];
GetModuleFileName(NULL, szFilePath, MAX_PATH);
(_tcsrchr(szFilePath, _T('//')))[1] = 0; //删除文件名,只获得路径
CString str_url = szFilePath; //str_url 中保存的是当前目录
java获取根路径有两种方式:
1)在servlet可以用一下方法取得:
requestgetRealPath(“/”)
例如:filepach = requestgetRealPath(“/”)+”//upload//”;
2)不从jsp,或servlet中获取,只从普通java类中获取:
String path = getClass()getProtectionDomain()getCodeSource()getLocation()getPath();
SAXReader() saxReader = new SAXReader();
if(pathindexOf(“WEB-INF”)>0){
path = pathsubstring(0,pathindexOf(“/WEB-INF/classes”)+16);
// ‘/WEB-INF/classes’为16位
document = saxReaderread(path+filename);
}else{
document = saxReaderread(getClass()getResourceAsStream(filename));
}
//获取当前进程的完整路径,包含文件名(进程名)。
string str = thisGetType()AssemblyLocation;
result: X:\xxx\xxx\xxxexe (exe文件所在的目录+exe文件名)
//获取新的Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
string str = SystemDiagnosticsProcessGetCurrentProcess()MainModuleFileName;
result: X:\xxx\xxx\xxxexe (exe文件所在的目录+exe文件名)
//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
string str = SystemEnvironmentCurrentDirectory;
result: X:\xxx\xxx (exe文件所在的目录)
//获取当前 Thread 的当前应用程序域的基目录,它由程序集冲突解决程序用来探测程序集。
string str = SystemAppDomainCurrentDomainBaseDirectory;
result: X:\xxx\xxx\ (exe文件所在的目录+"\")
//获取和设置包含该应用程序的目录的名称。
string str = SystemAppDomainCurrentDomainSetupInformationApplicationBase;
result: X:\xxx\xxx\ (exe文件所在的目录+"\")
//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
string str = SystemWindowsFormsApplicationStartupPath;
result: X:\xxx\xxx (exe文件所在的目录)
//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
string str = SystemWindowsFormsApplicationExecutablePath;
result: X:\xxx\xxx\xxxexe (exe文件所在的目录+exe文件名)
//获取应用程序的当前工作目录(不可靠)。
string str = SystemIODirectoryGetCurrentDirectory();
result: X:\xxx\xxx (exe文件所在的目录)
用 api 吧?QueryServiceConfig 函数可以获取服务配置信息
然后它会返回一个 QUERY_SERVICE_CONFIG 结构,里面的 lpBinaryPathName 成员就是文件路径,而 lpDescription 就是描述了
windows索引服务是windows *** 作系统提供的桌面搜索引擎,通过预先创建索引来提高对硬盘上文件内容的搜索速度。以windows服务程序的方式运行。 一、工作方式
1、对指定路径下的文件创建索引,并生成索引文件,索引文件的路径可以指定。
2、使用时,根据索引文件进行查询,不需要再次打开被索引的文件
二、使用方式
1、可以在windows搜索文件内容的时候指定使用索引服务,可以提高搜索速度。
2、windows索引服务对外提供DCOM等方式,可以通过COM接口访问。
3、可以与SQL SERVER结合,通过链接服务器(link server)的方式,配合SQL SERVER的全文检索语句进行搜索。
三、特点
1、只能提供静态摘要(文档开头的指定长度字节),不能生成动态摘要(类似Google的包含关键字的一段文字)。
2、使用远程的文件资源时,需要使用域名和密码对远程的windows共享资源进行访问,以便建立索引。
3、被索引的文件系统发生变化,索引可以自动更新。
4、文件系统庞大时,索引文件变大,搜索性能下降。
5、创建索引时,关键字词库有限,并且不能由用户增加新的关键字,会导致一些词汇不能被搜索,例如:C++
6、因和windows系统结合,可以支持html、txt、office文件等格式,如果需要支持其他文件,可以下载或者编写Filter,windows提供了编写Filter的标准接口。现有可以下载的Filter除了pdf格式Filter免费外,其它Filter的Server版都是收费的,Workstation版免费。
四、其他桌面搜索引擎
1、Google桌面搜索引擎
2、百度硬盘搜索等
五、总结
windows索引服务适合桌面搜索使用,在文件数量不是很大时可以提高全文检索速度。一些开源的java搜索引擎通常面向web搜索,较著名的有lucene等,有待研究。
=====================================================================
很多朋友对Windows *** 作系统中自带的搜索功能并不感冒,原因无他,因为搜索的速度实在是太慢了。正因如此,Google桌面搜索、百度硬盘搜索等第三方软件才能大行其道。其实,如果你使用的是Windows 2000或更高版本的 *** 作系统,应该激活Windows索引服务,这样在搜索文件时就能从索引数据库中快速查找所需要的文件了。
很多朋友都想知道java如何获取当前目录路径?下面就一起来了解一下吧~
1、利用SystemgetProperty()函数获取当前路径:
Systemoutprintln(SystemgetProperty("userdir"));//userdir指定了当前的路径
2、使用File提供的函数获取当前路径:
File directory = new File("");//设定为当前文件夹 try{ Systemoutprintln(directorygetCanonicalPath());//获取标准的路径 Systemoutprintln(directorygetAbsolutePath());//获取绝对路径 }catch(Exceptin e){} FilegetCanonicalPath()和FilegetAbsolutePath()大约只是对于new File("")和new File("")两种路径有所区别。 # 对于getCanonicalPath()函数,“"就表示当前的文件夹,而”“则表示当前文件夹的上一级文件夹 # 对于getAbsolutePath()函数,则不管””、“”,返回当前的路径加上你在new File()时设定的路径 # 至于getPath()函数,得到的只是你在new File()时设定的路径 比如当前的路径为 C:/test : File directory = new File("abc"); directorygetCanonicalPath(); //得到的是C:/test/abc directorygetAbsolutePath(); //得到的是C:/test/abc direcotrygetPath(); //得到的是abc File directory = new File(""); directorygetCanonicalPath(); //得到的是C:/test directorygetAbsolutePath(); //得到的是C:/test/ direcotrygetPath(); //得到的是 File directory = new File(""); directorygetCanonicalPath(); //得到的是C:/ directorygetAbsolutePath(); //得到的是C:/test/ direcotrygetPath(); //得到的是 另外:SystemgetProperty()中的字符串参数如下: SystemgetProperty()参数大全 # javaversion Java Runtime Environment version # javavendor Java Runtime Environment vendor # javavendorurl Java vendor URL # javahome Java installation directory # javavmspecificationversion Java Virtual Machine specification version # javavmspecificationvendor Java Virtual Machine specification vendor # javavmspecificationname Java Virtual Machine specification name # javavmversion Java Virtual Machine implementation version # javavmvendor Java Virtual Machine implementation vendor # javavmname Java Virtual Machine implementation name # javaspecificationversion Java Runtime Environment specification version # javaspecificationvendor Java Runtime Environment specification vendor # javaspecificationname Java Runtime Environment specification name # javaclassversion Java class format version number # javaclasspath Java class path # javalibrarypath List of paths to search when loading libraries # javaiotmpdir Default temp file path # javacompiler Name of JIT compiler to use # javaextdirs Path of extension directory or directories # osname Operating system name # osarch Operating system architecture # osversion Operating system version # fileseparator File separator ("/" on UNIX) # pathseparator Path separator (":" on UNIX) # lineseparator Line separator ("/n" on UNIX) # username User’s account name # userhome User’s home directory # userdir User’s current working directory
JAVA中获取路径 关键字: java中获取路径
1、jsp中取得路径:
以工程名为TEST为例:
(1)得到包含工程名的当前页面全路径:requestgetRequestURI() 结果:/TEST/testjsp (2)得到工程名:requestgetContextPath() 结果:/TEST (3)得到当前页面所在目录下全名称:requestgetServletPath() 结果:如果页面在jsp目录下 /TEST/jsp/testjsp (4)得到页面所在服务器的全路径:applicationgetRealPath("页面jsp") 结果:D:/resin/webapps/TEST/testjsp (5)得到页面所在服务器的绝对路径:absPath=new javaioFile(applicationgetRealPath(requestgetRequestURI()))getParent(); 结果:D:/resin/webapps/TEST
2、在类中取得路径: (1)类的绝对路径:ClassclassgetClass()getResource("/")getPath() 结果:/D:/TEST/WebRoot/WEB-INF/classes/pack/ (2)得到工程的路径:SystemgetProperty("userdir") 结果:D:/TEST
以上就是关于bcb 怎样获得服务程序的运行路径全部的内容,包括:bcb 怎样获得服务程序的运行路径、java怎么取到web服务的根路径、C#winform怎么获取服务器D盘的路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)