kamagra how much to take

Build SPFile Url’s Into A String Array

There was a question that was posted in the SharePoint development newsgroups as to how one would go about building the URL properties of SPFile objects into a string array. Here is a solution that seems to work just fine:

  1. SPFolder Folder;
  2.  
  3. int counter = Folder.Files.Count;
  4. string[] array = new string[counter + 1];
  5. int index = 1;
  6. foreach (SPFile file in Folder.Files)
  7. {
  8. array.SetValue(file.Url, index);
  9. index++;
  10. }
  11. Array.Sort(array);

You can see that we are firstly hydrating an SPFolder object representing the location where the holder of the relevant files are going to be looped through. Secondly, we declare the counter field that is going to take the SPFolder object and start a count on the files so that we can gauge the segments that are going to be built into the string array, incremented by uping the counter by a numeric of 1. Following, we are going to declare a index integer that is going to iterate through the SPFile objects that are in SPFolder.Files, then take the SPFile.URL property and add it to the string array. The result of which you could use for whatever. Obviously the SPFile.Url property could be adjusted to whatever SPFile property that you wanted, it wouldn’t have to be that. You could use it for doing other things like building an array of SPFile property metadata, or the likes if you wanted as well, pretty much whatever you want.

Hope this helps someone else.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>