Click here to Skip to main content
15,924,507 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionDeleting multiple rows Pin
TAK788-May-07 8:00
TAK788-May-07 8:00 
AnswerRe: Deleting multiple rows Pin
Dave Kreskowiak8-May-07 8:13
mveDave Kreskowiak8-May-07 8:13 
GeneralRe: Deleting multiple rows Pin
TAK788-May-07 8:39
TAK788-May-07 8:39 
GeneralRe: Deleting multiple rows Pin
TAK788-May-07 8:53
TAK788-May-07 8:53 
Questionsearch hard drive for files Pin
jds12078-May-07 7:36
jds12078-May-07 7:36 
AnswerRe: search hard drive for files Pin
MatrixCoder8-May-07 7:59
MatrixCoder8-May-07 7:59 
AnswerRe: search hard drive for files Pin
Dave Kreskowiak8-May-07 8:10
mveDave Kreskowiak8-May-07 8:10 
GeneralRe: search hard drive for files Pin
jds12078-May-07 10:21
jds12078-May-07 10:21 
I have started working on a search in a windows forms app but when I try to run the program I get the following security Exception

"Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

Here is my code:

Dim FilePath As String = TextBox1.Text
Dim FileType As String = TextBox2.Text
Dim diContents As New DirectoryInfo(FilePath)
Dim di As FileInfo
Dim filename As String = ListBox1.SelectedIndex
Dim testname As String

For Each di In diContents.GetFiles
Dim dirs() As String = Directory.GetFiles(FilePath & di.Name)
For Each filename In dirs
testname = System.IO.Path.GetFileName(filename)

Dim fileTest As String = testname.Remove(0, (Len(testname) - 3))
If UCase(fileTest) = FileType Then
ListBox1.Items.Add(testname)
End If
Next
Next
End Sub

Just to explain what I am trying to do, I want to enter the file path into the textbox where I want to search for the files. I want to enter the file extension(.txt, .mp3) into a textbox to specific what type of file I am looking for. Once the files are found, add them to the list box on the form. Is this code correct?

This line of code(Dim diContents As New DirectoryInfo(FilePath)) is highlighted when error occurs.

Any ideas?

jds1207
GeneralRe: search hard drive for files Pin
Dave Kreskowiak8-May-07 10:32
mveDave Kreskowiak8-May-07 10:32 
GeneralRe: search hard drive for files Pin
Dave Kreskowiak8-May-07 17:24
mveDave Kreskowiak8-May-07 17:24 
GeneralRe: search hard drive for files Pin
P P Vilsad8-May-07 21:21
P P Vilsad8-May-07 21:21 
AnswerRe: search hard drive for files Pin
P P Vilsad8-May-07 21:18
P P Vilsad8-May-07 21:18 
QuestionStart up Pin
scorp_scorp8-May-07 7:23
scorp_scorp8-May-07 7:23 
AnswerRe: Start up Pin
MatrixCoder8-May-07 7:55
MatrixCoder8-May-07 7:55 
AnswerRe: Start up Pin
nlarson118-May-07 7:58
nlarson118-May-07 7:58 
QuestionDataGridView - Display Row Numbers on Control Pin
RichardBerry8-May-07 4:26
RichardBerry8-May-07 4:26 
AnswerRe: DataGridView - Display Row Numbers on Control Pin
Rupesh Kumar Swami8-May-07 5:27
Rupesh Kumar Swami8-May-07 5:27 
GeneralRe: DataGridView - Display Row Numbers on Control Pin
RichardBerry8-May-07 7:43
RichardBerry8-May-07 7:43 
QuestionOffice 2007 ActiveX Pin
Stijn Courtheyn8-May-07 4:26
Stijn Courtheyn8-May-07 4:26 
QuestionNeed help with Word template Pin
Jats_4ru8-May-07 2:33
Jats_4ru8-May-07 2:33 
QuestionExtracting data from Web pages Pin
Farazj8-May-07 1:29
Farazj8-May-07 1:29 
Questionhow to access dynamically created control Pin
WorkingAcc8-May-07 1:07
WorkingAcc8-May-07 1:07 
GeneralRe: how to access dynamically created control [modified] Pin
Colin Angus Mackay8-May-07 2:26
Colin Angus Mackay8-May-07 2:26 
QuestionApplication Shortcut Pin
harsh_c7-May-07 21:56
professionalharsh_c7-May-07 21:56 
QuestionRe: Application Shortcut Pin
Jelle Stokroos7-May-07 22:33
Jelle Stokroos7-May-07 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.