Rename, delete MD in Filelistbox and dirlistbox

I want to be able to Rename, Delete and Make Directory in the FileListBox and the DirListBox. Have do I do that?
ChristianJAsked:
Who is Participating?
 
AllenC_JrConnect With a Mentor Commented:
Here is an example of renaming a file with a ListView.

Private Path as String
Private Sub RenameFile(FileNameFrom as String, FileNameTo as String)
If Not CheckFile(FileNameFrom) Then Exit Sub
FileCopy FileNameFrom, FileNameTo
Kill FileNameFrom
End Sub
Private Sub CheckFile(FileName as String)
Dim m_FLen as Long
CheckFile=True'Assume Success
On Error Resume Next
m_FLen = FileLen(FileName)
If ERR <>0 Then CheckFile=False
End Sub
Private Sub lvList_AfterLabelEdit(Cancel As Integer, NewString as String)
'*Note Replace The 'Path' With The Currently Viewed Directory(you could privately create a variable or keep it the same)
On Error Resume Next
If lvList.SelectedItem Is Nothing Then Exit Sub
If Right(Path, 1)  = "\" Then
RenameFile Path & lvList.SelectedItem.Text, Path & NewString
Else
RenameFile Path & "\" & lvList.SelectedItem.Text, Path & "\" & NewString
End If
End Sub

Hope This Helps
0
 
ChristianJAuthor Commented:
Edited text of question
0
 
ChristianJAuthor Commented:
This will mean a lot to me. I have tried to solve this on my own for month, but I didn't make it.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
rene100Commented:
what do you mean with ...in the filelistbox?
when you want to rename, del or md files/dirs, then you
can use the vb commands for this

re
0
 
wj7sterCommented:
You cannot do this from the FileListBox or DirListBox.  Use the VB commands:
'MkDir'  = Make directory
'RmDir'  = Remove (delete) directory
'Name oldpathname As newpathname' = rename/move a folder/file
0
 
ChristianJAuthor Commented:
In my program i have a filelistbox and when I mark a file I want to be able to rename it, or delete it.
0
 
ChristianJAuthor Commented:
If I change the filelist to a listview is it possible to use the commands RmDir, MkDir and delete (While runing the program)?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.