Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List box rename problem
Message
From
27/11/2002 18:36:31
 
 
To
27/11/2002 08:15:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00727522
Message ID:
00727810
Views:
8
>Hello
>
>i want to display file from c:\test directory in a list box and when the users right clicks on file it should prompt for new file name and when the users enters new file name i want to rename the file and update that filename in the listbox,how to do that.
>
>right now i have list box and in the init of the form
>
>DIMENSION cFile[1]
>lcDir = "c:\test\"
>Adir(cFile, lcDir + "*.*")
>IF ADIR(cFile,lcDir + "*.*") = 0
>	MESSAGEBOX('Sorry no files are present in the c:\test\ directory',0+16,'Please note')
>	RETURN .F.
>endif
>
>
>
>how to get new name and rename the file and update the list.
>
>thanks for any input.

Something like this
*** Load event
Public gc_Dir

gc_Dir = "c:\test\"

If (ADir(ThisForm.aFile, gc_Dir + "*.*") = 0)
   MESSAGEBOX('Sorry no files are present in the c:\test\ directory',0+16,'Please note')
   RETURN .F.
endif


*** ListBox RightClick Event
Local lc_FileRename, lc_Dir

lc_Dir = fullpath(sys(5))
Set default to (gc_Dir)
lc_FileRename = GetFile('*', 'Rename to', 'Rename', 0, 'Rename file "'+This.Value+'"')
If !empty(lc_FileRename)
   Rename (gc_Dir + This.Value) to (lc_FileRename)
   ThisForm.aFile[This.ListIndex,1] = JustFName(lc_FileRename)
   This.Refresh()
endif
Set default to (lc_Dir)
Herman
Previous
Reply
Map
View

Click here to load this message in the networking platform