.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to Split File from a specified path in a C#.net?

Posted By:Narayanan       Posted Date: September 25, 2011    Points: 40    Category: File Operation    URL: http://www.dotnetspark.com  

In this Code sample, How to get file name in a Specified path using C#.net?
 

string DesignationPath = @"C:\\Documents and Settings\\Narayanan\\My Documents\\Others\\Txt)";
string[] Dir;
Dir = Directory.GetFiles(C:\\Documents and Settings\\Narayanan\\My Documents\\Others\\Txt);
foreach (string str in Dir)
{
    string[] GFiles = str.Split('\\');
     string ExportPath =@"E:\"  + "\\" + GFiles[6];
      File.Copy(DesignationPath + "\\" + GFiles[6], ExportPath, true);
}

Step 1:
Here, Declare "Dir" for getting File Path

Step:2
Use Foreach statement for getting Specified Folder,Split a Path  ,Getting File Name from the Path  and Copy from one Location to another Location .



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend