|
-
Apr 26th, 2006, 04:35 PM
#1
Thread Starter
Lively Member
[RESOLVED] File.Copy() and other backuping information
I have the person locate files on the harddrive using the dialog boxes located in the SDK, however I have a problem. I add them to listboxes then use for...next loops to iterate through the lists, copying and pasting the files. Unfortunately, so far all attempts at that last part of drudged up nothing but exceptions inolving the existance of the file. I'm kinda stuck and the program is for a small business that a family member owns, so any help would be greatly apprectiated.
AZURE
Act 1: Ruby
Act 2: Cavara Militari
Act 3:
Act 4:
Act 5: Cogito ergo sum
-
Apr 26th, 2006, 05:07 PM
#2
Re: File.Copy() and other backuping information
Are they populating the listbox properly? can you post some code where your exception throws?
Bill
-
Apr 26th, 2006, 09:36 PM
#3
Thread Starter
Lively Member
Re: File.Copy() and other backuping information
IMPORTANT NOTE: I haven't added support for backing up folders and am not testing it.
VC#.net 2003
"System.IO.Exception
Target directory already exists"
I did put true in the file.copy method.
lstCopyFiles is the listbox that saves the file paths. lstDestination is the chance for multiple backups to be created. First block of code is what saves the path.
VB Code:
private void AddDeterminate(bool AddFile)
{
string FileName = "";
if(AddFile == true)
{
diaFiles.ReadOnlyChecked = true;
diaFiles.Multiselect = true;
diaFiles.InitialDirectory = "C:";
diaFiles.CheckFileExists = true;
diaFiles.CheckPathExists = true;
diaFiles.Title = "Specify files to be backed up";
diaFiles.ShowDialog(this);
FileName = diaFiles.FileName.ToString();
}
else
{
diaFolder.Description = "Specify folders to be backed up";
diaFolder.ShowDialog(this);
FileName = diaFolder.SelectedPath.ToString();
}
SaveUpdate = false;
lstCopyFiles.Items.Add(FileName);
}
And this is the exception throwing code:
VB Code:
private void BackUp()
{
lstDestination.SelectedIndex = 0;
int iCount;
int iCount2;
for(iCount = 0; iCount < lstCopyFiles.Items.Count;++iCount)
{
for(iCount2 = 0; iCount2 < lstDestination.Items.Count; ++iCount2)
{
lstCopyFiles.SelectedIndex = 0;
File.Copy(lstCopyFiles.SelectedItem.ToString(), lstDestination.SelectedItem.ToString(),true);
}
lstCopyFiles.Items.RemoveAt(0);
}
}
Last edited by PsychoticPsymon; Apr 27th, 2006 at 06:31 AM.
AZURE
Act 1: Ruby
Act 2: Cavara Militari
Act 3:
Act 4:
Act 5: Cogito ergo sum
-
Apr 27th, 2006, 05:03 PM
#4
Re: File.Copy() and other backuping information
File.Copy(lstCopyFiles.SelectedItem.ToString(), lstDestination.SelectedItem.ToString(),true);
On that line, is lstDestination.SelectedItem.ToString() giving you a full path or just the directory to put it in. It may be that you are only telling it the target directory, when you need to specify the whole thing..
I.e, for parameter 1: "C:\BILL\JOE.TXT"
for parameter 2: "C:\JOE\JOE.TXT" is ok but "C:\JOE\" is not ok..
Bill
-
Apr 28th, 2006, 07:03 PM
#5
Thread Starter
Lively Member
Re: File.Copy() and other backuping information
!!!
>.<
If I may be so upfront, Conipto, I love you.
AZURE
Act 1: Ruby
Act 2: Cavara Militari
Act 3:
Act 4:
Act 5: Cogito ergo sum
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
|