I am working on SharePoint Foundation 2010. I want to open file from a link.
I found a solution "Link To Document" content type. But in "Link To Document" content type we need filename of original file.
My Problem :
The filename can be changed any time. If I am using "Link To Document" content type then after changing the name the link will not work because the original filename is changed.
Can I create a link which will work using ID instead of name?
If yes then how? and if no then What could be the other ways to achieve this requirement?

Please Help.

  • Just to clarify are you trying to open a file using the SPItem.ID? Or am I way off base... – BlueBird Apr 5 '13 at 15:03
  • Yes, I want to open the file using SPItem.ID. I want to find the file like we are using ID in URL of EditForm and fetching the data. – MAK Apr 5 '13 at 16:10

My issue resolved. thanks for your effort and reply.


I have "Link to Document" content type. Before asking the question I was thinking that "Link To Document" content type will have link of document Eg: "http://{yourserve}/{documentLibrary}/ABC.txt" . After creating the link, original document name can be changed (i.e. ABC.txt to ABC1.txt ) but the link will be same and on click it will show the error like "File not found."

But after R and D, I found if I am using "Link To Document" content then if file name is changed then link will also change (i.e. Link will be "http://{yourserve}/{documentLibrary}/ABC1.txt"). and resolved my issue.

|improve this answer|||||
  • Actually to avoid name changing issue I was searching for ID. – MAK Apr 9 '13 at 6:26

Ok, if you already have SPItem you should be able to get the file using SPItem.File then you have access to all the SPFile properties.

However if you just have the ID and not the SPItem then you should be able to do this:

SPList olist = oWeb.Lists("LongList")
SPItem oitem = oList.GetItemById(123)            
SPFile oFile = oItem.File  

I hope that answers what you are looking for...

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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