0

How i would like to change my absolute Path to relative Path. anyone can help? this is my Code

string activeDirectory = @"X:\Temp\";
string[] files = Directory.GetFiles(activeDirectory);
foreach (string fileName in files)
{
   .....
}
H79
  • 335
  • 1
  • 5
  • 14
  • change how? You want a string holding the relative path? – James Michael Hare Sep 24 '12 at 14:56
  • 1
    Take a look at this. One of the first google results too, you should always try that first. http://softwareblog.alcedo.com/post/2010/02/24/Resolving-relative-paths-in-C.aspx – Kestami Sep 24 '12 at 14:57
  • Try the solution suggested [here], seems to be what you requested. [here]:http://stackoverflow.com/questions/275689/how-to-get-relative-path-from-absolute-path – Eyal H Sep 24 '12 at 20:53

1 Answers1

0

I would prefer files.Select(f => f.Substring(activeDirectory.Length)).
That means 'Skip x chars and return the rest'.

Johannes Egger
  • 3,874
  • 27
  • 36