Recently I've run in to the issue with MAX_PATH in the File/Directory library in .Net, so I started looking into alternatives.
I'm attempting to rebuild files from raw data stored in a database and have had no issues doing so so far using new FileStream("G:\Location\temp.txt", FileMode.Create)
etc, however I've been asked to change the structure of the rebuilt files, and thus run into the character limit.
I've attempted to use the example from Here, like this:
SafeFileHandle fileHandle = CreateFile(strDirectory,
EFileAccess.GenericWrite, EFileShare.None, IntPtr.Zero,
ECreationDisposition.OpenAlways, 0, IntPtr.Zero);
int lastWin32Error = Marshal.GetLastWin32Error();
if (fileHandle.IsInvalid)
{
throw new System.ComponentModel.Win32Exception(lastWin32Error);
}
Where strDirectory = "G:\Really\Long\Folder\Structure\Temp.txt"
However, I'm getting an 'Access is denied' exception being thrown. I have full Read/Write permissions to the target folder, so I'm not sure what the problem could be.
Any help would be much appreciated.