1

I am going through a code which is trying to make URL for a document within a document library,

string mydocumentpath = "https://" + spSite.HostName +
 MyDocumentlibrary.RootFolder.ServerRelativeUrl;

string mySecretEncodedPath = HttpUtility.UrlPathEncode(mydocumentpath ) + "/";

I am bit confused with where this root folder came from and what does "ServerRelativeUrl" is doing here, I already read this microsoft.sharepoint.splist.rootfolder.aspx but couldn't get answer I want.

Also is it alright to change root folder name ?

if it is then what would be the best way of doing it.

1 Answer 1

1

The url that you are generating with that code is in the form

http://MySite/MyLibrary

http:// + spSite.hostname can be replaced with spSite.Url to get the same effect.

ServerRelativeUrl is the part of the url after MySite so in this case it is just MyLibrary. MySite is the server or root.

The root folder of a library is the folder that is located at

http://MySite/MyLibrary 

any other folder you create in the library would have the url

http://MySite/MyLibrar/OtherFolder

You can rename the root folder by renaming the library because they are one and the same thing. Think of the library itself as a folder with certain properties that an ordinary folder doesn't have.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.