C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Moving file from sourcePath to DestinationPath


Posted Date: 07 Oct 2008    Resource Type: Code Snippets    Category: File Operations

Posted By: ravi       Member Level: Gold
Rating:     Points: 10



This code shows how to move a file from source tp destination

In Config file specify source path and destination Path:

for Ex:

<add key ="sourcepath" value="D:\Temp\Test" />
<add key ="destPath" value="D:\Default\Test\Sample"/>


In .CS file:


// strFileName is the FileName to be Moved to destination Folder

private void FileMove(string strFileName)
{

//Retriving sourcepath and Destination path from Config file

string strSourcePath = ConfigurationManager.AppSettings["sourcepath"];
string strdestPath = ConfigurationManager.AppSettings["destPath"];


if (!Directory.Exists(strdestPath )) // Checks for existness of destination directory
Directory.CreateDirectory(strdestPath); // if doesn't exists it creates dest'n directory

string strSourceFileName = strSourcePath+strFileName
string strDestFileName = strdestPath + strFileName ;

File.Move(strSourceFileName, strDestFileName); // Moves the file to Destination folder

Label1.Text = "File Moved Successfully";

}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
File Moving  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Retriving Values from an Excel Sheet
Previous Resource: Get the no of textfiles from a Directory
Return to Discussion Resource Index
Post New Resource
Category: File Operations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use