|
-
Jul 28th, 2012, 09:35 AM
#1
Thread Starter
Addicted Member
[RESOLVED] FolderBrowserDialog
Hey
how can say when the folder is selected (user pressed the ok )
go and do other thing..
2 more thing : i need to know all the files name that are in that folder that is selected
last thing : i know the files now how can i open each of them and read their content ...???
-
Jul 28th, 2012, 11:22 AM
#2
Re: FolderBrowserDialog
Look up My.Computer.FileSystem in MSDN or other tutorials for all the methods you're likely to need.
-
Jul 28th, 2012, 11:35 AM
#3
Re: FolderBrowserDialog
try this:
vb Code:
Dim files() As String
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = DialogResult.OK Then
files = IO.Directory.GetFiles(fbd.SelectedPath, "*.txt") 'get all text files in selected folder
End If
For Each file As String In files
Debug.Print(IO.File.ReadAllText(file))
Next
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 12:34 PM
#4
Thread Starter
Addicted Member
Re: FolderBrowserDialog
didnt work when i put it in Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Jul 28th, 2012, 12:45 PM
#5
Re: FolderBrowserDialog
it definitely works. i tested it. check the output in your immediate window (debug window)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 02:32 PM
#6
Thread Starter
Addicted Member
Re: FolderBrowserDialog
i got it work in listbox but its kinda messy..so i need to tell him when u reach to the end of the lenght character go to the new line hows that possible ??? so if i get to the new line i'll do i+=1 and then go to the new file and on and on ....and i need to know the file name too ?!
Last edited by Pc Monk; Jul 28th, 2012 at 02:38 PM.
-
Jul 28th, 2012, 02:51 PM
#7
Re: FolderBrowserDialog
instead of io.file.readalltext use:
io.file.readalllines + the listbox's items.addrange method.
if you're not sure how to do that post your code + i'll show you how to change it
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 03:05 PM
#8
Thread Starter
Addicted Member
Re: FolderBrowserDialog
to be honest i dont know how to do it
the program is going to take a directory which theres full of .php and .tpl files in it ...
read every php and tpl file line by line
then sum them all and tell the user that all the php and tpl lines are example of 1000 lines together
here is what i have that u told me already
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim files() As String
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = DialogResult.OK Then
files = IO.Directory.GetFiles(fbd.SelectedPath, "*.txt") 'get all text files in selected folder
End If
For Each file As String In files
ListBox1.Items.AddRange((IO.File.ReadAllLines(file))
Next
End Sub
End Class
i changed it but nothing happend !
-
Jul 28th, 2012, 03:16 PM
#9
Re: FolderBrowserDialog
you just want a sum of all the line counts of all of the .php and .tpl files in a directory?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 03:19 PM
#10
Thread Starter
Addicted Member
Re: FolderBrowserDialog
any programming prefix ..php css tpl txt html xml ...those that u can open them with notepad too ..not prefix like VS and ...
Last edited by Pc Monk; Jul 28th, 2012 at 03:28 PM.
-
Jul 28th, 2012, 03:27 PM
#11
Re: FolderBrowserDialog
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim files As New List(Of String)
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = DialogResult.OK Then
files.AddRange(IO.Directory.GetFiles(fbd.SelectedPath, "*.php")) 'get all php files in selected folder
files.AddRange(IO.Directory.GetFiles(fbd.SelectedPath, "*.tpl")) 'get all tpl files in selected folder
'repeat for all file types
End If
MsgBox(files.Sum(Function(f) IO.File.ReadAllLines(f).Length))
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 03:42 PM
#12
Thread Starter
Addicted Member
Re: FolderBrowserDialog
thanks for that ....the only thing is i have directory into directory ..like template1 theres 10 .php and in the template folder theres a css folder that contain 4 .css file in there but this will only go for root..so how can it go into other directory and count those lines as well
-
Jul 28th, 2012, 03:55 PM
#13
Re: FolderBrowserDialog
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim files As New List(Of String)
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog = DialogResult.OK Then
files.AddRange(IO.Directory.GetFiles(fbd.SelectedPath, "*.php", IO.SearchOption.AllDirectories)) 'get all php files in selected folder
files.AddRange(IO.Directory.GetFiles(fbd.SelectedPath, "*.tpl", IO.SearchOption.AllDirectories)) 'get all tpl files in selected folder
'repeat for all file types
End If
MsgBox(files.Sum(Function(f) IO.File.ReadAllLines(f).Length))
'if you want to put all of the filenames in your listbox
listbox1.items.addrange(Array.ConvertAll(files.ToArray, Function(f) New IO.FileInfo(f)))
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 28th, 2012, 04:08 PM
#14
Thread Starter
Addicted Member
Re: FolderBrowserDialog
thank you so much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|