开发者

Problem with Illegal Characters in SQL Server Assembly

开发者 https://www.devze.com 2023-03-16 03:06 出处:网络
I am working with Directory.GetFiles in C#.This code is turned in开发者_如何学运维to an assembly which is then used in a T-SQL script.Here is the code line that I believe is the problem:

I am working with Directory.GetFiles in C#. This code is turned in开发者_如何学运维to an assembly which is then used in a T-SQL script. Here is the code line that I believe is the problem:

C# Code:

string[] filePaths = Directory.GetFiles(path, ext, SearchOption.AllDirectories);

Error (T-SQL script):

System.IO.DirectoryNotFoundException: Could not find a part of the path 'G:\Photography\Archive\SPBKF3~L'.

I'm assuming the tilde isn't a legal character to use for a folder name in Windows because the only folders that cause this error are the ones with a tilde. The files are being shared between Mac and Windows systems and I've found that file and folder names have been a problem in the past.

I'm having a difficult time understanding why the Directory.GetFiles method would even find a directory that doesn't exist. The folder displays in Windows Explorer but I cannot access the folder.

Is there something I can do to avoid these problem folders?


SPBKF3~L looks suspiciously like an 8.3 shortened filename. Are you sure this isn't happening somewhere?


~ is not an invalid character - I just tried creating a directory with the name SPBKF3~L, and I also wrote up a quick C# app to run your sample code on that directory and it worked fine.

There must be something else happening here - are you absolutely sure that the directory exists? (try copying and pasting the path into an explorer window)


Check the permissions on G:\Photography\Archive\SPBKF3~L and ensure that the user account the SQL Server instance is running under can see the folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消