如何在C#中获取系统路径 [英] how to get system path in c#
问题描述
C:\ Documents and Settings \ purplelab>路径
PATH = C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ WINDOWS \ SYSTEM32 \ WBEM; c:\ Program Files \ Mi
crosoft SQL Server \ 100 \ Tools \ Binn \; c:\ Program Files \ Microsoft SQL Server \ 100 \ DTS
\ Binn \; C:\ WINDOWS \ system32 \ WindowsPowerShell \ v1.0; c:\ Program Files \ Microsoft SQL
Server \ 100 \ Tools \ Binn \ VSShell \ Common7 \ IDE \; C:\ Program Files \ Common Files \ Adobe \
AGL
如何在c#中获取这些路径?
C:\Documents and Settings\purplelab>path
PATH=C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;c:\Program Files\Mi
crosoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS
\Binn\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Program Files\Microsoft SQL
Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Common Files\Adobe\
AGL
how to get these paths in c#?
推荐答案
可以使用
You can use
Console.WriteLine(Environment.GetEnvironmentVariable("Path"));
这将为您提供所需的路径.
希望能有所帮助.如果是这样,请标记answe/upvote.
谢谢
Milind
This will give you path as you want.
Hope that helps. If it does, mark the answe /upvote.
Thanks
Milind
嗨
您可以使用C#目录类获取文件路径和系统文件路径
这是链接 http://msdn.microsoft.com/en-us/library/system.io.directory.aspx [ ^ ]
祝您编码愉快!
Storxstar
Hi
you can get filepaths and system filepaths using the C# directories class
here is a link http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^]
Happy Coding!
Storxstar
在
中明确提到了答案 http://msdn.microsoft.com/en-us/library/77zkk0b6.aspx
仔细阅读链接.
The answer is clearly mentioned in
http://msdn.microsoft.com/en-us/library/77zkk0b6.aspx
Read the link carefully.
这篇关于如何在C#中获取系统路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!