2

I've been reading some answers on stack overflow specifically.. Get file name from a path string in C#. My problem is that after I've added using System.IO; above the namespace. Then attempted to call the method Path.GetFileNameWithoutExtension(fullPath);, I can't because the Path Class has not been included within my System.IO reference.

System.IO.Path
(source: iforce.co.nz)

Even though I'm using .NET framework 4.0 with VisualStudio 2010.

FM Target
(source: iforce.co.nz)

Could the using System.Windows.Shapes; reference cause issues with the System.IO reference? why can't I use the Path Class (even though MSDN states that .NET Framework 4.0 is compatible)??

Community
  • 1
  • 1
classicjonesynz
  • 4,012
  • 5
  • 38
  • 78

1 Answers1

2

System.IO.Path is not a valid using directive. All you need to do is remove it!

using System.IO; is adequate enough, then Path.GetFileNameWithoutExtension() validates fine:

The Path is a class and System.IO is the namespace.

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134