找不到文件的路径

发布于 2024-11-29 05:27:30 字数 401 浏览 3 评论 0原文

我一直在尝试访问以下路径以从目录中读取一些文件,但没有成功,并抛出 System.IO.DirectoryNotFound 异常。

string pathname = @"\AppData\Local\Google\Chrome\User Data\Default\FileSystem\000"

使用以下代码:

 string[] fileNames = Directory.GetFiles(pathname);

但是我仍然可以手动找到指定的目录,并且要读取的文件仍然在那里。

任何人都可以帮我解决这个问题吗?

如果我无法访问 FileSystem 目录,我如何读取该目录中的文件。

真挚地, 德里克

I have been trying to access the following path to read some files from the directory but I have been unsuccessful with an System.IO.DirectoryNotFound Exception being thrown.

string pathname = @"\AppData\Local\Google\Chrome\User Data\Default\FileSystem\000"

using the following code :

 string[] fileNames = Directory.GetFiles(pathname);

However I can still locate the specified directory manually and my files to be read are still there.

Could Anyone Help Me Out On The Solutions To This Issue ?

If I cant access the FileSystem directory,how can i read the files inside that directory.

Sincerely,
Derek

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

单挑你×的.吻 2024-12-06 05:27:30

而不是直接访问 AppData\Local,而不管用户配置文件驻留在文件系统上的位置。

string AppDataLocalPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
string pathname = AppDataLocalPath + "\Google\Chrome\User Data\Default\FileSystem\000";

您可以使用This should return 提供路径,

Rather than accessing AppData\Local directly, instead could you use

string AppDataLocalPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
string pathname = AppDataLocalPath + "\Google\Chrome\User Data\Default\FileSystem\000";

This should return provide the path, regardless of where the user profile resides on the file system.

半﹌身腐败 2024-12-06 05:27:30

确保路径正确:

string pathname = @"\AppData\Local\Google\Chrome\User Data\Default\FileSystem\000"

由于第一个反斜杠,将在驱动器的根目录中查找该路径(即 C:\AppData\Local\Google\Chrome\User Data\Default\000)。

Make sure the path is correct:

string pathname = @"\AppData\Local\Google\Chrome\User Data\Default\FileSystem\000"

Will look for that path in the root of the drive (i.e., C:\AppData\Local\Google\Chrome\User Data\Default\000) because of the first backslash.

无语# 2024-12-06 05:27:30

从 Microsoft 下载一个名为“Process Monitor”的工具来验证实际使用的文件路径:http ://technet.microsoft.com/en-us/sysinternals/bb896645

提示:“进程监视器”实时监视硬盘驱动器、注册表和线程/进程信息,并允许您保存其痕迹捕获。

一个。打开Process Monitor,它将开始跟踪信息。

b.通过单击“放大镜”工具栏按钮(其“开/关”跟踪按钮)来停止跟踪。

c.然后单击清除跟踪按钮以清除跟踪。

d.准备重现 System.IO.DirectoryNotFound 异常。

e.然后单击进程监视器中的开始跟踪按钮。

f.快速重现 System.IO.DirectoryNotFound 异常。

g。发生错误后,通过取消单击“放大镜”工具栏按钮来停止“进程监视器”跟踪。

h.查看日志,检查文件路径是否正确。

我有一种感觉,这会让您看到不正确的目录/路径。

Download a tool called "Process Monitor" from Microsoft to verify what file path is actually being used: http://technet.microsoft.com/en-us/sysinternals/bb896645

Tip: "Process Monitor" monitors Hard Disk Drive, Registry and Thread/Process information in real time and allows you to save the traces it captures.

a. Open Process Monitor, it will start tracing information.

b. Stop the trace by clicking the Magnifying Glass toolbar button (its the On/Off tracing button).

c. Then click the Clear trace button to clear the trace.

d. Prepare to reproduce the System.IO.DirectoryNotFound Exception.

e. Then click the Start trace button in Process Monitor.

f. Quickly reproduce the System.IO.DirectoryNotFound Exception.

g. After the error has occurred, Stop the "Process Monitor" trace by un-clicking the Magnifying Glass toolbar button.

h. View the log and check the file path is correct.

I have a feeling this will allow you to see the incorrect directory/path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文