Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Rename, delete MD in Filelistbox and dirlistbox

Posted on 1998-09-14
7
534 Views
Last Modified: 2012-05-04
I want to be able to Rename, Delete and Make Directory in the FileListBox and the DirListBox. Have do I do that?
0
Comment
Question by:ChristianJ
7 Comments
 

Author Comment

by:ChristianJ
ID: 1434787
Edited text of question
0
 

Author Comment

by:ChristianJ
ID: 1434788
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
 
LVL 2

Expert Comment

by:rene100
ID: 1434789
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 2

Expert Comment

by:wj7ster
ID: 1434790
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
 

Author Comment

by:ChristianJ
ID: 1434791
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
 

Author Comment

by:ChristianJ
ID: 1434792
If I change the filelist to a listview is it possible to use the commands RmDir, MkDir and delete (While runing the program)?
0
 
LVL 2

Accepted Solution

by:
AllenC_Jr earned 50 total points
ID: 1434793
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 208
VBA open file from excel cell 4 44
passing parameter in sql procedure 9 65
Add and format columns in vb6 7 63
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question