|
-
May 30th, 2015, 10:57 AM
#1
Thread Starter
Member
Coping Files With Underscore at beginning. Selected Object Only & Clear List box
Hello,
Currently This displays all of the files that are in the Folder "Granite" Which are videos in Listbox1 & Listbox2. I want to make it so that only selected objects in listbox1 will be copyed with the same name but have a underscore at the beginning (_). Currently it all works but copy's all files listed in the listbox1 and not selected. Selection Mode is set to MultiSimple.
Also, I want it so that when I press copy it repopulates listbox2 with all the new files (Clears and then displays current Files) but it just stacks it after all items that are already in there. Or I want it so that no matter what it is always checking and syncing to the folder. One or the other.This does not work
Code:
ListBox2.Items.Clear()
Lastly, All Files that have been copied to the Underscore format cant be copied again it just makes the program fail. I want it so that even if the file was _FILE1 and if it is copied again it would look like this: __FILE1
Current Code:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim directory1 = "C:\Server Media\Granite"
Dim files() As System.IO.FileInfo
Dim dirinfo1 As New System.IO.DirectoryInfo(directory1)
files = dirinfo1.GetFiles("*", IO.SearchOption.AllDirectories)
For Each file In files
ListBox1.Items.Add(file)
Next
Dim directory2 = "C:\Server Media\Granite"
Dim files2() As System.IO.FileInfo
Dim dirinfo2 As New System.IO.DirectoryInfo(directory2)
files2 = dirinfo2.GetFiles("*", IO.SearchOption.AllDirectories)
For Each file In files
ListBox2.Items.Add(file)
Next
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
For Each o As Object In ListBox1.Items
'My.Computer.FileSystem.DeleteFile("C:\Server Media\WVII Playback\" & o.ToString)
My.Computer.FileSystem.CopyFile("C:\Server Media\Granite\" & o.ToString, "C:\Server Media\Granite\" + "_" & o.ToString)
Next
Dim directory1 = "C:\Server Media\Granite"
Dim files() As System.IO.FileInfo
Dim dirinfo1 As New System.IO.DirectoryInfo(directory1)
files = dirinfo1.GetFiles("*", IO.SearchOption.AllDirectories)
For Each file In files
ListBox2.Items.Add(file)
Next
End Sub
-
May 30th, 2015, 11:41 AM
#2
Re: Coping Files With Underscore at beginning. Selected Object Only & Clear List box
to copy selected files only:
Code:
For Each o As Object In ListBox1.SelectedItems
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 30th, 2015, 11:58 AM
#3
Thread Starter
Member
Re: Coping Files With Underscore at beginning. Selected Object Only & Clear List box
 Originally Posted by .paul.
to copy selected files only:
Code:
For Each o As Object In ListBox1.SelectedItems
Thanks, That works great. now I just need to get the rest of it working! thank you.
-
May 31st, 2015, 07:26 AM
#4
Thread Starter
Member
Re: Coping Files With Underscore at beginning. Selected Object Only & Clear List box
I was able to get Listbox2 to clear with the following code:
Code:
ListBox2.Items.Clear()
ListBox2.Refresh()
I still am in search of trying to make it so that if a file that is "_FILE.mov" (1 Underscore) that the program does not fail if it is accidentally clicked on and copied to what should then be "__FILE.MOV" (2 Underscore)
This is kind of confusing because from what I'm seeing is if I close and open the application back up and click a file with an underscore already "_FILE.MOV" (1 Underscore) it will copy it to "__FILE.MOV" (2 Underscore) it fails if that file is clicked on again and the copy button is pushed again. how can I fix that issue?
Tags for this Thread
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
|