我怎样才能访问"文档和设置"夹? [英] How can I access the "Documents and Settings" folder?

查看:175
本文介绍了我怎样才能访问"文档和设置"夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#.NET 4 VS 2010

I'm using C# .NET 4 with VS 2010.

当过一些路径遍历,我跑这条线:

When Iterating over some paths, I'm running this line:

files = Directory.GetFiles(path, searchPattern);



我得到一个异常时的路径是文档和设置文件夹。我怎样才能访问它?不,我不想用try和catch跳过的文件夹。我希望能够以某种方式访问​​

I get an exception when the path is the documents and settings folder. How can I access it? And no, I don't want to skip the folder with a try and catch. I want to be able to access it somehow.

编辑:我有一个跟进的问题。正如我告诉你,我遍历的路径。有没有办法使用 Environment.GetFolderPath 但根据我目前正在检查的路径在某种程度上idetifying正确的文件夹调校妥当?

I got a follow up question. As I told you, I'm iterating over the paths. Is there a way to use Environment.GetFolderPath but somehow idetifying the correct speical folder according to the path I'm currently checking?

推荐答案

您必须使用这样的

var mydocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

要访问该我的文档文件夹中。

这篇关于我怎样才能访问"文档和设置"夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆