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

Top 5 Contributors of the Month
Sandeep Singh

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

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:


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