Click here to Skip to main content
15,920,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
System.IO.File.Copy(PhotoPath + @"\" + filename, P_Path, true);


i am using above line for if file name is already exist then replace it. but it is not work, it is not replace...
Posted
Updated 8-Jul-14 21:00pm
v2

That code works for me - the true at the end allows File.Copy to overwrite existing files.

So, it's probably a permissions, bad file path, or "file in use" problem. Check for exceptions and look at what is being returned. For example, it could be that PhotoPath already includes a trailing '\' so your source path is invalid.

Use the debugger in cases like this: we can't see your screen, access your HDD, or read your mind so we can't just give you a solution!
 
Share this answer
 
Try like this

C#
System.IO.File.Copy(Path.Combine(PhotoPath,filename), P_Path, true);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900