Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System.IO Namespace
Directory Class
Directory Methods
GetFiles Method

  Switch on low bandwidth view
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Directory..::.GetFiles Method

Returns the names of files in a specified directory.

  NameDescription
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkGetFiles(String) Returns the names of files in the specified directory.
Public methodStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkGetFiles(String, String) Returns the names of files in the specified directory that match the specified search pattern.
Public methodStatic memberGetFiles(String, String, SearchOption) Returns the names of files in the specified directory that match the specified search pattern, using a value to determine whether to search subdirectories.
Top
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
GetFiles Returns Filepaths      David Rogers ... Thomas Lee   |   Edit   |   Show History

GetFiles does not return file names, rather it returns either relative or absolute filepaths, depending on the form of the directory specification given. For example, assume the calling process has a working directory of "C:\TEMP" and that "C:\TEMP" contains two files: "A.Dat" and "B.Dat".

GetFiles("C:\\TEMP") will return:

"C:\TEMP\A.Dat"

"C:\TEMP\B.Dat"

GetFiles("C:") will return:

"C:A.Dat"

"C:B.Dat"

GetFiles(".") will return:

".\A.Dat"

".\B.Dat"

getting file names instead of paths      lucky0ne ... Shauna Liu   |   Edit   |   Show History
If you want just file names not paths you can use Path.GetFileName.

More on Path.GetFileName here
http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker