I need to create folders with trailing dots (.) using C#. Here is my code:
System.IO.Directory.CreateDirectory("d:\\MyCorp Inc.");
But the folder is created without the final dot. Is there a solution?
I am using .NET Framework 4.5/C#. My file system is NTFS, on Windows 8.
Try:
using System.Runtime.InteropServices;
class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool CreateDirectory(string lpPathName, IntPtr lpSecurityAttributes);
private static void Main(string[] args)
{
CreateDirectory(@"\\?\c:\temp\MyCorp Inc.", IntPtr.Zero);
}
And refer to You cannot delete a file or a folder on an NTFS file system volume.