所以我有一个非常基本的问题就在这里......我们必须依赖于一个XML文件存储设置的应用程序。偶尔这个文件被破坏,应用程序在启动时会失败。我想编写一个应用程序来查找USED文件和BACKUP文件。应用程序使用的文件由于各种原因(10年更改等)并不总是存储在同一位置,但它始终命名相同。如何避免被拒绝(只是检查文件名)访问
这样的想法是我写的这个简单的应用程序,它可以去找到系统上的文件的所有情况下(通常一个或两个HDD)很明显是用于并且是备份。
简单......但同时,通过使用此代码
Private Sub Command1_Click(sender As System.Object, e As System.EventArgs) Handles Command1.Click
'variable to hold each hdd name eg: c:\
Dim hdd As String
Try
For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives
'asign the variable hdd a name for this run through
hdd = drive.Name
'search the hdd for the file user.config
For Each filename As String In IO.Directory.GetFiles(hdd, "user.config", IO.SearchOption.AllDirectories)
'variable to hold the path for each found file
Dim file As String = IO.Path.GetFullPath(filename)
'add each found file to the list
List1.Items.Add(file)
Next
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'iterate through each found drive
End Sub
我得到的是拒绝访问的问题迭代...
所以我觉得我应该能之前只检查权限我对它做了什么?但是,我认为我没有真正尝试做任何事情,只是阅读正确吗?还是我失去了一些东西......
我试图改变权限,运行VS2010管理员等等这些都不奏效。
TIA
好了,这就是我猜我是愚蠢的。我认为尝试捕捉会这样做,但它会退出。我将不得不做一些看看我在那里错过了什么......感觉我会在大约3分钟内感到愚蠢。 – jsteffler 2014-12-02 21:26:55