简体   繁体   English

在Sql Server FileTable中创建子目录

[英]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.

相关问题 SQL Server Express是否支持FileTable - Does SQL Server Express support FileTable SQL Server Profiler 中的 filetable_updates 表 - filetable_updates table in SQL Server Profiler 如何访问存储在SQL Server FileTable中的文件? - How to access files stored in SQL Server's FileTable? SQL Server 2012 FileTable映射到已安装的S3虚拟目录 - SQL Server 2012 FileTable mapped to a mounted S3 Virtual Directory SQL Server 2014:更新File_Stream.PathName()时触发FileTable - SQL Server 2014 : FileTable trigger on update File_Stream.PathName() 如何使用SqlFileStream对SQL Server 2012 FileTable进行事务性访问? - How to use SqlFileStream for transactional access to SQL Server 2012 FileTable? 如何在SQL Filetable中的目录下插入文件 - How to insert a file under a directory in SQL Filetable 在Windows资源管理器中创建文件,锁定FileTable - Create file in Windows Explorer locking FileTable 使用ASP.NET网站中的File.CreateFile将文件插入Sql Server 2012 FileTable时访问被拒绝 - Access Denied when inserting file into Sql Server 2012 FileTable using File.CreateFile in ASP.NET website 无法使用Dapper.NET将文件流插入SQL文件表 - Unable to insert file stream into SQL filetable using Dapper.NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM