RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 1686 | Replies: 4 | Solved
Reply
Join Date: Jul 2005
Location: FL.
Posts: 1,536
Reputation: tayspen is on a distinguished road 
Rep Power: 7
Solved Threads: 98
Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Basic Question

  #1  
Nov 25th, 2005
I mam having problems doing somthing fairly simple. . What i have is a listview with about 1000 items in it. All files paths that i have scanned from a directory. And there are 4 colums. First the name, then the size, extesion ect. the last is the path to the file. Right now the user can click to copy them and they are all copied to a differ location. Thats easy....they can also choose to just copy the one checked one. Thats easy to i used this
 try
            {
                string s = Registry.CurrentUser.OpenSubKey(@"Software\ManagePod\GeneralConfig", true).GetValue("CopyDir").ToString();   
                string mp3 = listViewFiles.SelectedItems[0].SubItems[3].Text.ToString();
                MP3File mp3File = ShellID3TagReader.ReadID3Tags(mp3);
                File.Copy(mp3, s + "\\" + mp3File.SongTitle + "-" + mp3File.ArtistName + ".mp3");
            }
            catch
            {

                //error handling
            }

Now what i want to be able to do is let the user copy any files that are Checked.. So say they check off six files. On a button click i want the six checked files copied to the target location. Now i no this should be easy. But i am strugling witht the subitems part. I have somthing like this.
//so here is some puesdo code
foreach(4th column of every checked item)//the 4th column is that path
{
File.Copy(the path of each 4th selected item, target loaction
}

Thanks for any help

-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Basic Question

  #2  
Nov 25th, 2005
foreach (ListViewItem lvi in this.listViewFiles.CheckedItems)
			{
// do whatever here
				string s =  lvi.SubItems[3];
			}
Reply With Quote  
Join Date: Jul 2005
Location: FL.
Posts: 1,536
Reputation: tayspen is on a distinguished road 
Rep Power: 7
Solved Threads: 98
Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Basic Question

  #3  
Nov 25th, 2005
Originally Posted by r0ckbaer
foreach (ListViewItem lvi in this.listViewFiles.CheckedItems)
			{
// do whatever here
				string s =  lvi.SubItems[3];
			}

Thanks. But i hd tried somthing similar to that and it failed. So did yours. See when i do the copy functin it says that path is not supported. so using this code

 foreach (ListViewItem lvi in this.listViewFiles.CheckedItems)
            {
                string s = lvi.SubItems[3].ToString();
                MessageBox.Show(s);       
            }

I had a messagebox show me it, it looks like this

ListViewItem: {thepath}

thats not going to work. Any ideas?

btw this is the code i tried to use to copy it. but because of the format it didnt work.

 string s1 = Registry.CurrentUser.OpenSubKey(@"Software\ManagePod\GeneralConfig", true).GetValue("CopyDir").ToString();   //this is an entry in th e reg it is the path to a dir. this case the dir where it will be copied to.
            foreach (ListViewItem lvi in this.listViewFiles.CheckedItems)
            {
                string s = lvi.SubItems[3].ToString();
                MP3File mp3File = ShellID3TagReader.ReadID3Tags(s);//class to read MP3's
                File.Copy(s, s1 + "\\" +  mp3File.SongTitle + "-" + mp3File.ArtistName + ".mp3");
                
            }
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: Basic Question

  #4  
Nov 25th, 2005
lvi.SubItems[3].Text
Reply With Quote  
Join Date: Jul 2005
Location: FL.
Posts: 1,536
Reputation: tayspen is on a distinguished road 
Rep Power: 7
Solved Threads: 98
Colleague
tayspen's Avatar
tayspen tayspen is offline Offline
<Insert title here>

Re: Basic Question

  #5  
Nov 25th, 2005
Thanks that did it

-T

P.s that was easy
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes

Member - Alliance of Security Analysis Professionals - Since 2006
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:13 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC