Good point. The trailing space is caused by another process and really needs to be corrected there. I'm going to treat these as exceptions and not process them if there is no solution to the problem.
The directory is on a Linux server. Linux allows trailing spaces in the directory name. I have a mapped drive on a Windows server to the Linux server. Windows recognizes the trailing space in the mapped drive directory name and C# recognizes the trailing space when listing the directories...
The code is shown below. Please note that the error occurs on the line "ListDirectoriesAndFiles(dInfo.GetFileSystemInfos());". The directory string is "Z:\incoming\foldernamewithspace ".
<code>
using System;
using System.IO;
class DirectoryIssue
{
static void Main()
{
try...
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...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.