On Nov 10, 5:26*pm, "Ben" <b...@fd.dcwrote:
Hi,
i need the filename of files located in a directory.
I use this:
Directory.GetFiles(Server.MapPath("~/mydirectory/")
For Each fileName In fileEntries
name=fileName
next
but this guves the full path. Any way to get only the filename? Of coursei
can use substring, but does it exist a function?
Thanks
Ben
' Create a reference to the current directory.
Dim di As New DirectoryInfo(Environment.CurrentDirectory)
' Create an array representing the files in the current
directory.
Dim fi As FileInfo() = di.GetFiles()
Console.WriteLine("The following files exist in the current
directory:")
' Print out the names of the files in the current directory.
Dim fiTemp As FileInfo
For Each fiTemp In fi
Console.WriteLine(fiTemp.Name)
Next fiTemp
http://msdn.microsoft.com/en-us/libr...info.name.aspx
Hope this helps