首页  编辑  

文件名是否有效

Tags: /超级猛料/Stream.File.流、文件和目录/文件操作/   Date Created:

function IsValidFileName(const FileName: string): boolean;

const

 InValidChar: array[0..8] of char = ('\', '/', ':', '*', '?', '"', '<', '>', '|');

var

 i: integer;

begin

 result:=length(FileName) <= MAX_PATH;

 if not Result then exit;

 for i := low(InValidChar) to high(InValidChar) do

 begin

   result := pos(InValidChar[i], FileName) = 0;

   if not Result then break;

 end;

end;