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?


3 Answers 3


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


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.

  • Yes, but still no luck :(
    – kd22
    Commented Mar 18, 2014 at 15:15
  • Have you tried to paste the link in the address bar of your browser?
    – Hinek
    Commented Mar 19, 2014 at 11:55
  • yes, it works fine when copied directly in the browser
    – kd22
    Commented Mar 19, 2014 at 19:56
  • 1
    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
    Commented Mar 20, 2014 at 15:33

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}”/

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.