[英]Create subdirectory in Sql Server FileTable
I have a simple script that creates subdirectory in FileTable: 我有一个简单的脚本,可以在FileTable中创建子目录:
INSERT INTO MyFiles (name, is_directory)
VALUES ('SomeFolder', 1, 0)
It works corrrect and if I run it SqlServer creates subdirectory 'SomeFolder'. 它工作正确,如果我运行它,SqlServer将创建子目录“ 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
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: 据我所知,我必须为父文件夹添加parent_path_locator列,例如:
INSERT INTO MyFiles (name, is_directory, parent_path_locator)
VALUES ('SecondLevel', 1, pathLocatorForFirstLevel)
But I have not pathLocatorForFirstLevel
cause FirstLevel
is not created yet. 但是我还没有pathLocatorForFirstLevel
因为尚未创建FirstLevel
。 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. 使用某些C#代码,可以快速验证和创建该文件夹(如果该文件夹不存在)。
using System.IO;
DirectoryInfo di = Directory.CreateDirectory(FileServerPath + @"\" + 'FirstLevel\SecondLevel');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.