AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Inkompatible Typen: Char und 'String'
Thema durchsuchen
Ansicht
Themen-Optionen

Inkompatible Typen: Char und 'String'

Ein Thema von Crazymodder · begonnen am 8. Feb 2009 · letzter Beitrag vom 10. Jun 2009
Antwort Antwort
Benutzerbild von markus5766h
markus5766h

Registriert seit: 5. Mär 2009
Ort: Hamburg
569 Beiträge
 
Delphi XE8 Professional
 
#1

Re: Inkompatible Typen: Char und 'String'

  Alt 9. Jun 2009, 21: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.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz