Pascal => C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Pascal => C#

    Hi Guys,

    Is there a reference that would help someone coming from Delphi to
    find equivalent functions in C#?

    I'm currently looking for a C# version of Delphi's
    IncludeTrailing PathDelimiter() . This function accepts a string and
    returns the string with a trailing path delimiter (/ or \ depending on
    platform). If the string already has the trailing delimiter, it is
    returned unmodified.

    I know I'll run into other translation issues so if anyone could point
    me to a good reference, I'd appreciate it.

    Thanks,
    Steve
  • Tom Porterfield

    #2
    Re: Pascal => C#

    Steve wrote:
    Hi Guys,
    >
    Is there a reference that would help someone coming from Delphi to
    find equivalent functions in C#?
    >
    I'm currently looking for a C# version of Delphi's
    IncludeTrailing PathDelimiter() . This function accepts a string and
    returns the string with a trailing path delimiter (/ or \ depending on
    platform). If the string already has the trailing delimiter, it is
    returned unmodified.
    >
    I know I'll run into other translation issues so if anyone could point
    me to a good reference, I'd appreciate it.
    I'm not sure that specific method exists in C# but it would be simple to
    write:

    public string IncludeTrailing PathDelimiter(s tring path)
    {
    if (path.EndsWith( System.IO.Path. DirectorySepara torChar.ToStrin g()))
    {
    return path;
    }
    else
    {
    return (path + System.IO.Path. DirectorySepara torChar);
    }
    }
    --
    Tom Porterfield

    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: =?ISO-8859-1?Q?Pascal_=3D& gt;_C#?=

      Steve <kilroy@harpser vices.comwrote:
      Is there a reference that would help someone coming from Delphi to
      find equivalent functions in C#?
      Not that I'm aware of - although Jon Shemitz's book ".NET 2.0 for
      Delphi developers" may well be useful to you.
      I'm currently looking for a C# version of Delphi's
      IncludeTrailing PathDelimiter() . This function accepts a string and
      returns the string with a trailing path delimiter (/ or \ depending on
      platform). If the string already has the trailing delimiter, it is
      returned unmodified.
      >
      I know I'll run into other translation issues so if anyone could point
      me to a good reference, I'd appreciate it.
      If the bigger picture is that you're trying to create a full filename
      given a parent directory and the next level (whether that's a file or
      another directory name) Path.Combine is your friend.

      --
      Jon Skeet - <skeet@pobox.co m>
      http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
      World class .NET training in the UK: http://iterativetraining.co.uk

      Comment

      • Michael A. Covington

        #4
        Re: Pascal =&gt; C#


        "Steve" <kilroy@harpser vices.comwrote in message
        news:lvdbl351ln tu4jpshaj90ti8d gem75n0pb@4ax.c om...
        Hi Guys,
        >
        Is there a reference that would help someone coming from Delphi to
        find equivalent functions in C#?
        >
        I'm currently looking for a C# version of Delphi's
        IncludeTrailing PathDelimiter() . This function accepts a string and
        returns the string with a trailing path delimiter (/ or \ depending on
        platform). If the string already has the trailing delimiter, it is
        returned unmodified.
        I don't think that's a built-in function, but it sounds like about 3 lines
        of code...


        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: Pascal =&gt; C#

          Michael A. Covington wrote:
          "Steve" <kilroy@harpser vices.comwrote in message
          news:lvdbl351ln tu4jpshaj90ti8d gem75n0pb@4ax.c om...
          >I'm currently looking for a C# version of Delphi's
          >IncludeTrailin gPathDelimiter( ). This function accepts a string and
          >returns the string with a trailing path delimiter (/ or \ depending on
          >platform). If the string already has the trailing delimiter, it is
          >returned unmodified.
          >
          I don't think that's a built-in function, but it sounds like about 3 lines
          of code...
          A bit of googling indicates that it is part of Delphi starting
          from Delphi 7.

          But it should be easy to achieve the desired functionality
          using the System.IO.Path class.

          Arne

          Comment

          • Liz

            #6
            Re: Pascal =&gt; C#


            "Steve" <kilroy@harpser vices.comwrote in message
            news:lvdbl351ln tu4jpshaj90ti8d gem75n0pb@4ax.c om...
            Hi Guys,
            >
            Is there a reference that would help someone coming from Delphi to
            find equivalent functions in C#?
            >
            I'm currently looking for a C# version of Delphi's
            IncludeTrailing PathDelimiter() . This function accepts a string and
            returns the string with a trailing path delimiter (/ or \ depending on
            platform). If the string already has the trailing delimiter, it is
            returned unmodified.
            I know I'll run into other translation issues so if anyone could point
            me to a good reference, I'd appreciate it.

            Maybe this book would be of some use:

            ..NET 2.0 For Delphi Programmers


            but I have to think your ultimate best reference is the .NET Framework Class
            Library Reference; you have to learn the FCL anyway


            Comment

            Working...