DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

.NET - Save image from one folder to another folder

By Ashok Nalam on 24 Mar 2014 | Category: ASP.NET | Tagged: file C# ASP.NET 
Sometimes we need to copy an image from one folder to another folder. The snippet shows how to copy file using System.IO.File.Copy for ASP.NET, Console and Windows Application.
  Discuss Add Comment   |  
Add rating Rate this resource   

Introduction

Sometimes we need to copy an image from one folder to another folder. The snippet shows how to copy file using System.IO.File.Copy.

System.IO.File.Copy(Server.MapPath("/sourcefolder/myimage.jpg"), Server.MapPath("/destinationfolder/myimage1.jpg"));

Copy method takes 2 arguments

1st - source file path

2nd - destination file path

sourcefolder & destinationfolder are folders in your ASP.NET project.

Note: Server.MapPath works for ASP.NET. If you want to use it for console/windows application just pass the path of the file like below

System.IO.File.Copy(@"c:\myimage.jpg", @"c:\testfolder\myimage1.jpg");
  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9526  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys