Registriert seit: 5. Mär 2009
Ort: Hamburg
569 Beiträge
Delphi XE8 Professional
|
Re: Inkompatible Typen: Char und 'String'
9. Jun 2009, 22:22
Hallo,
@Melli012345
hab' hier 'ne Funktion zum Löschen von Zeichen in Verzeichnissen/Pfaden,
lässt sich mit wenig AUfwand für deine Zwecke "umbauen"
Delphi-Quellcode:
function CheckInvalidChars(const FilePath: String): String; // replace invalid Path-File-Chars
var
sFilePath, sFileName: String;
l, i : Integer;
Const
RePath : array[1..13] of String =
('/', '*', '?', '"', '<', '>', '|', '!', '§', '$', '%', '&', '#'); // Chars to replace in Path
ReFile : array[1..15] of String =
('/', '\', ':', '*', '<', '>', '?', '"', '|', '!', '§', '$', '%', '&', '#'); // Chars to replace in File
ReP : String = '_'; // replace invalid chars in Path with '_'
ReF : String = '_'; // replace invalid chars in File with '_'
begin
l := 0;
for i := 1 to Length(FilePath) do
begin
if FilePath[i] = '\' then l := i;
end;
sFileName := copy(FilePath, l+1, length(FilePath)-l+1);
sFilePath := copy(FilePath, 0, l);
// File - Path, check and replace
for i := 1 to 13 do
sFilePath := StringReplace(sFilePath, RePath[i], ReP, [rfReplaceAll, rfIgnoreCase]);
// File - Name, check and replace
for i := 1 to 15 do
sFileName := StringReplace(sFileName, ReFile[i], ReF, [rfReplaceAll, rfIgnoreCase]);
Result := sFilePath + sFileName;
end;
Markus H.
|