raymondhvh
Gebruiker
- Lid geworden
- 31 okt 2008
- Berichten
- 131
Laat maar ik heb dit al
nu zit ik met het probleem dat ik van mijn documenten
bestanden wil scannen maar de toegang tot mijn documenten en dan Videos zijn geweigert..
ik heb hier de Error
System.UnauthorizedAccessException: Toegang tot het pad C:\Users\Raymond\Documents\My Videos is geweigerd.
bij System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bij System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
bij System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
bij DestroyRoulette.Form1.GetFiles(String SourceFolder, String Filter, SearchOption searchOption) in C:\Users\Raymond\Documents\Visual Studio 2008\Projects\DestroyRoulette\DestroyRoulette\Form1.vb:regel 46
bij DestroyRoulette.Form1.Timer2_Tick(Object sender, EventArgs e) in C:\Users\Raymond\Documents\Visual Studio 2008\Projects\DestroyRoulette\DestroyRoulette\Form1.vb:regel 23
en hier mijn code
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Enabled = False
Dim Rand As New Random
Try
Dim Files() As String = GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "*.gif|*.jpg|*.png|*.bmp|*.exe|*.doc|*.zip|*.rar|*.txt|", SearchOption.AllDirectories)
Label2.Text = Files(Rand.Next(0, Files.Length))
Catch ex As Exception
TextBox1.Text = ex.ToString
End Try
Dim r As New Random
Label3.Text = r.Next(1, 2)
MsgBox("Het juiste getal is" & Label3.Text)
If Label3.Text = "1" Then
MsgBox("Ronde 2")
Else
MsgBox("bijna" & Label2.Text & "kwijt!")
End If
End Sub
Public Function GetFiles(ByVal SourceFolder As String, ByVal Filter As String, ByVal searchOption As SearchOption) As String()
Dim alFiles As ArrayList = New ArrayList()
Dim MultipleFilters() As String = Filter.Split("|")
For Each FileFilter As String In MultipleFilters
alFiles.AddRange(Directory.GetFiles(SourceFolder, FileFilter, searchOption))
Next
Return alFiles.ToArray(Type.GetType("System.String"))
End Function
nu zit ik met het probleem dat ik van mijn documenten
bestanden wil scannen maar de toegang tot mijn documenten en dan Videos zijn geweigert..
ik heb hier de Error
System.UnauthorizedAccessException: Toegang tot het pad C:\Users\Raymond\Documents\My Videos is geweigerd.
bij System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bij System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
bij System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
bij DestroyRoulette.Form1.GetFiles(String SourceFolder, String Filter, SearchOption searchOption) in C:\Users\Raymond\Documents\Visual Studio 2008\Projects\DestroyRoulette\DestroyRoulette\Form1.vb:regel 46
bij DestroyRoulette.Form1.Timer2_Tick(Object sender, EventArgs e) in C:\Users\Raymond\Documents\Visual Studio 2008\Projects\DestroyRoulette\DestroyRoulette\Form1.vb:regel 23
en hier mijn code
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Enabled = False
Dim Rand As New Random
Try
Dim Files() As String = GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "*.gif|*.jpg|*.png|*.bmp|*.exe|*.doc|*.zip|*.rar|*.txt|", SearchOption.AllDirectories)
Label2.Text = Files(Rand.Next(0, Files.Length))
Catch ex As Exception
TextBox1.Text = ex.ToString
End Try
Dim r As New Random
Label3.Text = r.Next(1, 2)
MsgBox("Het juiste getal is" & Label3.Text)
If Label3.Text = "1" Then
MsgBox("Ronde 2")
Else
MsgBox("bijna" & Label2.Text & "kwijt!")
End If
End Sub
Public Function GetFiles(ByVal SourceFolder As String, ByVal Filter As String, ByVal searchOption As SearchOption) As String()
Dim alFiles As ArrayList = New ArrayList()
Dim MultipleFilters() As String = Filter.Split("|")
For Each FileFilter As String In MultipleFilters
alFiles.AddRange(Directory.GetFiles(SourceFolder, FileFilter, searchOption))
Next
Return alFiles.ToArray(Type.GetType("System.String"))
End Function
Laatst bewerkt: