0

I have a partialView which lists out filepaths and I need to be able to click on that path and open the containing folder. The app was working locally and process.start() worked just fine until we moved to a production server and now a solution is needed for it. The browsers security restrictions won't allow me to open the containing folder directly. Is there a way to accomplish this?

Current setup, pretty basic stuff

 public ActionResult OpenFile(string path, int someId)
    {
        Process.Start("explorer.exe", Path.GetDirectoryName(path));    

The view looks like this

 @foreach (var file in Model.FileSet)
                {
                    var path = @file.FilePath;
                    <tr>
                        <td><a href='@Url.Action("Action", "Controller", new{path = @path, someId = Model.Id})'> @file.FilePath </a></td>
                        <td>@file.FileType</td>
                        <td>@file.Created</td>
                    </tr>
                }
            </tbody>

Any help is appreciated.

Salman Syed
  • 568
  • 5
  • 9

1 Answers1

0

The code Process.Start is done on server side and even probably works if you check server process list.

You can only add download functionality, but I don't know if this fulfills your requirements.

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
  • Thanks @Garath,The files are downloaded through a separate process and reside on the client machine. The file location is stored in the database and listed on the app. So, something that can open files on the local client machine is what i am looking for. – Salman Syed Dec 03 '14 at 05:47
  • @SalmanSyed you should read this: http://stackoverflow.com/questions/5246292/open-local-folder-from-link – Piotr Stapp Dec 03 '14 at 07:31
  • I did look at it before posting my question but thought there's someone out there who encountered this and resolved it. – Salman Syed Dec 03 '14 at 16:32
  • @SalmanSyed it cannot be resolved because in all browser, because most of them just block this because of security reasons. If you really need such functionality the only option is to use java applet and communicate with it using javascript. – Piotr Stapp Dec 03 '14 at 19:06