I have a directory that ends with a period (.), created by rsync via Cygwin on a Windows server.
The code I have tries to read a file inside this directory but I get an exception saying that it “Could not find a part of the path” and the ending period is missing from the path the program tries to read.
Is it possible to read directories ending in a period via C#?
Thank you for any help.
Code beeing used:
StreamReader sr = null;
try
{
sr = new StreamReader(@"<path_ending_in_period>", System.Text.Encoding.Default);
}
catch (Exception ex)
{
....
}
Check the Test() method below. It has examples for both local and UNC path, and works with files ending in a dot. The code is based on the code found at Link, which also has code for deleting the file.
Basically you get a FileHandle from the Win32 API, and pass it on to .Net.
[Edit – new code]