Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2007
    Posts
    15

    String.TrimLeft help

    Hi. I'm trying to get a simple thing to work: get the working path, then remove that string from the path of an image file. But I can't get it to work right. This is my code

    Code:
    working = Folder.GetCurrent();
    i_prop = Image.GetProperties("Image1");
    i_folder = i_prop.ImageFile;
    
    path = String.TrimLeft(i_folder, working);
    The working folder is C:\Builds\My Project\CD_ROOT\
    The image file path is C:\Builds\My Project\CD_ROOT\AutoPlay\Images\Image1.png

    I expected to get "AutoPlay\Images\Image1.png" out of the TrimLeft action, but instead I get "Image1.png"...? What am I not understanding here?

    Thanks!!

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    use String.Replace

    working = Folder.GetCurrent();
    i_prop = Image.GetProperties("Image1");
    i_folder = i_prop.ImageFile;

    path = String.Replace(i_folder, working,"");

    will return "AutoPlay\\Images\\Image1.png"
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Sep 2007
    Posts
    15
    You're a good man!

    Thank you very much.

  4. #4
    Join Date
    Sep 2007
    Posts
    15
    But... I get "AutoPlay\Images\Image1.png" and not with the "\\". How could I change this automatically?
    can you tell I'm not very good with the String functions?

    (Sorry bouble post, but I missed the 15 minute timer...)

  5. #5
    Join Date
    Dec 2007
    Location
    Missouri, United States
    Posts
    476
    use another string replace and use this as your substring "\\" and use this as your replace string "\\\\"

  6. #6
    Join Date
    Sep 2007
    Posts
    15
    Makes sense. Thank you!

Similar Threads

  1. String.TrimLeft()
    By clueless in forum AutoPlay Media Studio 6.0
    Replies: 3
    Last Post: 01-27-2007, 06:23 AM
  2. BAD BUG with THIS FUNCTION: String.TrimLeft
    By DjArko85 in forum AutoPlay Media Studio 6.0
    Replies: 3
    Last Post: 09-24-2006, 04:56 AM

Posting Permissions

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