Add to elements of a string array

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

    Add to elements of a string array

    Hi
    I have a file list box with which i am passing the selected items to a
    string array (using copyTo), however i also need to pass the path of
    the FLB with each string in the array. Is it possible to add this to
    each element of the array or is there another approach i could take.

    Thanks

    Colin Williams

  • Bruce Wood

    #2
    Re: Add to elements of a string array


    Colin Williams wrote:
    Hi
    I have a file list box with which i am passing the selected items to a
    string array (using copyTo), however i also need to pass the path of
    the FLB with each string in the array. Is it possible to add this to
    each element of the array or is there another approach i could take.
    I would create a new string array of the same size and build each file
    name into a full path and put it in the new string array, effectively
    transforming the array you have of file names into another array of
    file paths.

    Comment

    • Colin Williams

      #3
      Re: Add to elements of a string array

      Thanks for the reply.

      Could you give me some advice on how to do that.

      Here is the code so far.

      int iCount = 0;

      iCount = flbsource.Selec tedItems.Count;
      string spath = flbsource.Path + "\\";

      String[] source = new String[iCount];

      flbsource.Selec tedItems.CopyTo (source, 0);

      Thanks
      Colin

      Comment

      • Bruce Wood

        #4
        Re: Add to elements of a string array


        Colin Williams wrote:
        Thanks for the reply.
        >
        Could you give me some advice on how to do that.
        >
        Here is the code so far.
        >
        int iCount = 0;
        >
        iCount = flbsource.Selec tedItems.Count;
        string spath = flbsource.Path + "\\";
        >
        String[] source = new String[iCount];
        >
        flbsource.Selec tedItems.CopyTo (source, 0);
        How about something like:

        string spath = flbsource.Path + @"\";
        string[] selectedPaths = new string[flbsource.Selec tedItems.Count];
        for (int i = 0; i < flbsource.Selec tedItems.Count; i++)
        {
        selectedPaths[i] = spath + flbsource.Selec tedItems[i];
        }

        ?

        Comment

        • Colin Williams

          #5
          Re: Add to elements of a string array

          Thanks

          Comment

          Working...