Click here to Skip to main content
15,913,334 members
Home / Discussions / C#
   

C#

 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
shadowthief_0310-Feb-10 9:53
shadowthief_0310-Feb-10 9:53 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
Keith Barrow10-Feb-10 10:08
professionalKeith Barrow10-Feb-10 10:08 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
shadowthief_0310-Feb-10 10:35
shadowthief_0310-Feb-10 10:35 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
Keith Barrow10-Feb-10 11:21
professionalKeith Barrow10-Feb-10 11:21 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
shadowthief_0310-Feb-10 10:53
shadowthief_0310-Feb-10 10:53 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
Eddy Vluggen10-Feb-10 11:14
professionalEddy Vluggen10-Feb-10 11:14 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
shadowthief_0310-Feb-10 11:24
shadowthief_0310-Feb-10 11:24 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
Keith Barrow10-Feb-10 11:38
professionalKeith Barrow10-Feb-10 11:38 
Where does this break, and what is the message?

In the code:

shadowthief_03 wrote:
foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}




Don't re-use the variables fileName or destFile, declare with different names, or you'll get the world of pain later.
There is a danger (in fact I *think* it is certain) that the loop above will re-copy the file copied in the first line inside the method you posted. You will get an access denied message if that file is marked as read only on the file system (i.e. recopying onto a readnly file already copied). You could try removing that line from the code.
Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
shadowthief_0310-Feb-10 11:56
shadowthief_0310-Feb-10 11:56 
GeneralRe: Moving a file from a CD to a Folder somewhere on hardrive Pin
Eddy Vluggen10-Feb-10 12:00
professionalEddy Vluggen10-Feb-10 12:00 
QuestionHow to Load & Save to val's in app.config file ? Pin
Gali197810-Feb-10 7:59
Gali197810-Feb-10 7:59 
AnswerRe: How to Load & Save to val's in app.config file ? Pin
Dan Mos10-Feb-10 8:27
Dan Mos10-Feb-10 8:27 
QuestionUserControl Designer Support Pin
Andy Braham10-Feb-10 7:32
Andy Braham10-Feb-10 7:32 
Questionwant code Pin
ajay 201010-Feb-10 7:08
ajay 201010-Feb-10 7:08 
AnswerMessage Closed Pin
10-Feb-10 7:31
stancrm10-Feb-10 7:31 
GeneralRe: want code Pin
ajay 201011-Feb-10 1:09
ajay 201011-Feb-10 1:09 
AnswerRe: want code Pin
Dan Mos10-Feb-10 7:31
Dan Mos10-Feb-10 7:31 
GeneralRe: want code Pin
ajay 201011-Feb-10 1:16
ajay 201011-Feb-10 1:16 
GeneralRe: want code Pin
ajay 201011-Feb-10 1:20
ajay 201011-Feb-10 1:20 
GeneralRe: want code Pin
ajay 201011-Feb-10 1:21
ajay 201011-Feb-10 1:21 
RantRe: want code Pin
Bram van Kampen10-Feb-10 15:47
Bram van Kampen10-Feb-10 15:47 
AnswerWant Ferrari Pin
J4amieC10-Feb-10 21:53
J4amieC10-Feb-10 21:53 
QuestionUpdate a Desktop Application by Dowloading a File Pin
PDTUM10-Feb-10 6:58
PDTUM10-Feb-10 6:58 
AnswerRe: Update a Desktop Application by Dowloading a File Pin
Giorgi Dalakishvili10-Feb-10 7:11
mentorGiorgi Dalakishvili10-Feb-10 7:11 
GeneralRe: Update a Desktop Application by Dowloading a File Pin
PDTUM11-Feb-10 6:32
PDTUM11-Feb-10 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.