Directories managment,.

devimore

Member
Joined
Jul 1, 2010
Messages
9
Programming Experience
5-10
Hey, guys.
I have a little problem..
So im writing an application for Windows Mobile 6 sdk in VB .NET and im making a file explorer.. Like build in file explorer, but much more suitable for me.. Because i think that build in file explorer is cinde of pore..
Bu i run in little problem..
So i have this code to list files and folders in listview:

============= CODE ==============
Public Sub load_listview()
ListView1.Clear()

'add columns
ListView1.Columns.Add("Name", 200, HorizontalAlignment.Left)
ListView1.Columns.Add("Size", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Type", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Creation Time", 120, HorizontalAlignment.Left)

'Dim files and folders
Dim folderInfo As New IO.DirectoryInfo(string_current_folder)
Dim allFilesInFolder() As IO.FileInfo
Dim fileInFolder As IO.FileInfo

Dim folder As IO.DirectoryInfo
'Dim allFolders As IO.DirectoryInfo

allFilesInFolder = folderInfo.GetFiles("*.*")

'folders
For Each folder In folderInfo.GetDirectories
Dim str(5) As String
Dim itm As ListViewItem
str(0) = folder.Name.ToString
str(1) = "izmers"
str(2) = "folder"
str(3) = folder.CreationTime.ToString

itm = New ListViewItem(str)
itm.ImageIndex = 1
ListView1.Items.Add(itm)
Next

' files
For Each fileInFolder In allFilesInFolder
Dim str(4) As String
Dim itm As ListViewItem
str(0) = fileInFolder.Name.ToString
str(1) = "the size" 'file size
str(2) = fileInFolder.Extension.ToString
str(3) = fileInFolder.CreationTime.ToString
itm = New ListViewItem(str)
ListView1.Items.Add(itm)
Next
============= CODE ==============


Sow everything is working fine..
When i need to go to some filder i just add to path the clicked listview item and its done, but..
I need to go somehow back..
And its a big problem for me now..
Sow my question is, is there a way or a tool to manage folders, to get the folder thats back one level from the current one..

P.S. Sorry about my bad english.
 
if you know the path of the directory in variable string_current_folder you could just do a lastindexof search for the folder seperator (usually "\")

VB.NET:
''  filling in dummy data
string_current_folder="C\Folder1\Folder2\Folder3"
dim sNextFolderUp as string = string_current_folder.substring(0, string_current_folder.lastindexof("\"))

sNextFolderUp should then be the folder one level up from string_current_folder
 
Last edited:
Back
Top