Question

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.
Question:
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.
Thanks.

Was it helpful?

Solution

My issue resolved. thanks for your effort and reply.

Explanation:

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."

Solution:
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.

OTHER TIPS

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...

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top