I have a simple script that creates subdirectory in FileTable:
INSERT INTO MyFiles (name, is_directory)
VALUES ('SomeFolder', 1, 0)
It works corrrect and if I run it SqlServer creates subdirectory 'SomeFolder'. But if I try to create nested subfolder I face with an error:
INSERT INTO MyFiles (name, is_directory)
VALUES ('FirstLevel\SecondLevel', 1)
Error message is: An invalid filename, 'FirstLevel\\SecondLevel', caused a FileTable check constraint error. Use a valid Windows filename
An invalid filename, 'FirstLevel\\SecondLevel', caused a FileTable check constraint error. Use a valid Windows filename
.
As I know I must add parent_path_locator column for parent folder, for instance:
INSERT INTO MyFiles (name, is_directory, parent_path_locator)
VALUES ('SecondLevel', 1, pathLocatorForFirstLevel)
But I have not pathLocatorForFirstLevel
cause FirstLevel
is not created yet. Maybe anyone know how to create subfolder with arbitrary name?
Using some C# code, the folder can be quickly verified and created if it does not exist.
using System.IO;
DirectoryInfo di = Directory.CreateDirectory(FileServerPath + @"\" + 'FirstLevel\SecondLevel');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.