SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, I am new to server side development (especially SP development) and I don't know if this is possible but here goes:

I have a custom list which I populate from a local folder on my file system. The folder has many nested folders and files of different formats.

I added a custom ECB menu item for this particular list and I want to be able to open the file (either in the browser or the specific application) when the menu item in the ECB menu for a list item is clicked.

Here's what I have for e.g.:

SPUserCustomAction action = list.UserCustomActions.Add();
action.Url = "file:///C://Users//Administrator//Desktop//Dir//file1.txt";

But when I click the custom menu item in ECB, I get a browser alert saying: Invalid Page URL.

Am I missing something or is there a particular way of opening files by any other method that can help my issue?

share|improve this question
it gives the same browser alert even after using my server name i.e. file://servername/full_path but in vain – kd22 Mar 18 '14 at 14:36
possible duplicate of SharePoint 2013 link files from local drive or network drive – MdMazzotti May 12 '15 at 7:58

This should be

action.Url = "file:///C:/Users/Administrator/Desktop/Dir/file1.txt";

Triple slash after the file:, then single slashes (not double) instead of the filesystem backslashes.

share|improve this answer
Yes, but still no luck :( – kd22 Mar 18 '14 at 15:15
Have you tried to paste the link in the address bar of your browser? – Hinek Mar 19 '14 at 11:55
yes, it works fine when copied directly in the browser – kd22 Mar 19 '14 at 19:56
have you checked (with a brwoser developer tool F12 or source view), what link is finally rendered in the HTML page and if it differs from the Link you want? – Hinek Mar 20 '14 at 15:33

For Security Reasons, the browser does not allow Code to Access the local file System. Paths to local files require to be given by the user directly (eg. calling it using the Address-Box or selecting it for file upload).

share|improve this answer

As you can see in msdn, the value inserted in the URL property cannot be a path to a local file.

enter image description here

Instead, a valid value is a relative path to the site. Example:


In your case, once you have the list populated with the files, the url action should point to the list item, not to the local file. Please try with:

action.Url = ”~site/SitePages/Home.aspx?ID={ItemId}&List={ListId}”/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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