Results 1 to 5 of 5

Thread: CreateDirectories

  1. #1
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default CreateDirectories

    Example:
    - we have a folder named A at C:\
    - we want to create the folder named C at C:\A\B
    - B does not exists so CreateDirectory('C:\A\B\C\'); wont work

    Here is my solution:

    CreateDirectories('C:\A\B\C\D\E\F\G\H\');

    Simba Code:
    procedure CreateDirectories(const FilePath : String);
    var
      Folders : Array of String;
      i : Integer;
    begin
      Folders := Explode('\',FilePath);
      for i:=1 to (High(Folders)-1) do
        CreateDirectory(Folders[0] + Between(Folders[0],Folders[i+1],FilePath));
      CreateDirectory(FilePath);
    end;

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    ForceDirectories('C:/Test2/test3/test4/');
    Working on: Tithe Farmer

  3. #3
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    ForceDirectories('C:/Test2/test3/test4/');
    Wow, wasted an hour for this.

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Now I feel like an ass. Oh well, at least simba's function supports both / and \
    Working on: Tithe Farmer

  5. #5
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Now I feel like an ass. Oh well, at least simba's function supports both / and \
    Well at least I learnt some string functions in pascal.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •