Recently, I created a thread about a long path I have to deal with.
Basically, a file name exists in a path. The path and the file name exceeds 260 characters. Thus, this creates an error if we try to verify if this file exists. The method I am using had been adjusted to add a second level of verification in case File.Exists() cannot find the file. This will be the case if the full path exceeds 260 characters. The method will then fall in the second level of verification to do a split, first check for the existence of the directory and then check for the file in that directory.
However, in order to check for a file in a directory, I am using this approach:
loFiles = loDirectoryInfo.GetFiles(lcFilter)
But, I get this:
"The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."
loDirectoryInfo is properly initialized from a 101 character length. lcFilter is the file and contains 158 characters. Adding the \ between the two gives 260 characters. That produces the error. I am looking for an alternative to detect the presence of a file. In such circumstances, I would need an alternative route as this exists on the disk but I can't verify if it exists.