Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1650 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > ASP.NET Interview Questions > How can we copy the file from one locati ...

How can we copy the file from one location to other?

Interview question and answer by: Lakhangarg | Posted on: 11/4/2009 | Category: ASP.NET Interview questions | Views: 2605 |


Answer:

Using File.Copy Method we can copy the file from one location to other.

System.IO.File.Copy("Source File Path", "Destination File Path");

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


 Responses

Posted by: Raja | Posted on: 04 Nov 2009 10:54:43 PM | Alert Moderator 

Dear you should provide complete related information about this. Like the source and destination file path will be like phyiscal path not virtual path.

Just to add
Server.MapPath("/root/myfolder") will give the physical path of the folder from starting from the driver letter that can be used in place of "Source File Path" and "Destination File Path".

So the ammended code snippet may look like

System.IO.File.Copy(Server.MapPath("/root/source/a.xml"), Server.MapPath("/root/destination/b.xml"));


Thank you.

Lakhan, please do not mind, just an effort to provide complete info :)

Cheers

Posted by: Lakhangarg | Posted on: 04 Nov 2009 11:01:14 PM | Alert Moderator 

Good Effort Raja, Thanks :)

>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Lakhangarg

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/18/2013 10:56:05 AM