I have a mapped drive to a Linux mount and need to search for files. One of the directories has a trailing space in the name and this produces the DirectoryNotFoundException error when using the DirectoryInfo.GetFiles method. It seems the method trims the trailing space by default. I am hoping someone has found a workaround for this issue. I'm using C# 2005. I also get the same error when using the GetFileSystemInfos method.

I've looked on their implemetation (DirectoryInfo implementation) and they format string (Directory path) in the constructor like to get the full internal path and so on, so you don't have anything. the idea is Windows Platform hasn't such type of directories. You may use any open source of C# which intended to run on such operating systems which permit using space in the end of directory name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.