我有一台windows服务在我的机器上运行。 我怎样才能得到每个用户的Mydocuments文件夹?
例如:
对于windows XP,我必须得到列表:
C: documents and Settings User1 My documents
C: documents and Settings User2 My documents
…
对于windows 10我必须得到列表:
使用VisualStyles控件的边框颜色
模拟磁盘空间exception
单声道的pdfSharp
如何在.NET中映射需要用户名和密码的networking驱动器?
如何允许外部加载项与.net 3.0应用程序轻松接口?
C:用户用户1 文件
C:用户用户2 文件
…
我怎样才能得到这些名单?
在C#中将USB设备名称映射到COM端口?
如何在C#应用程序中将embedded式PowerShell会话configuration为64位
Powershell:pipe道input到通过调用运算符执行的命令
处理数据库模式中的更改
如何使我的服务停止自动发布到windows应用程序事件日志
我会建议使用此解决方案 ,然后枚举文件夹(每个用户)。
// getUserProfilesPath() is a method from https://stackoverflow.com/a/41752173/3179310 string path = getUserProfilesPath(); // Now use WMIC to get all users on the local machine Selectquery query = new Selectquery("Win32_UserAccount"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(query); foreach (ManagementObject result in searcher.Get()) { // and check if their folder exists if(Directory.Exists(Path.Combine(path,result["name"]))) { // user folder exists so Now check if it has documents folder if(DirectoryExists(Path.Combine(path,result["name"],"documents"))) { DirectoryInfo userdocuments = new DirectoryInfo(Path.Combine(path,"documents")); // userdocuments is Now a directory info of that user's documents folder } } }
总结以上是内存溢出为你收集整理的获取每个用户的SpecialFolder.MyDocuments文件夹全部内容,希望文章能够帮你解决获取每个用户的SpecialFolder.MyDocuments文件夹所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)