0

In my project, I have a fileupload control for user to upload their document and I want to provide a link to user to open their files.

steps: after user upload a file, my web will create a link for it when user click on that link, the container folder of that file will open.

For example, a file which its path is C:\Users\John\Downloads\jpg\a.jpg uploaded to the fileupload control. when user click on the link of that file, a folder C:\Users\John\Downloads\jpg will be opened.

To get the file path:

string filePath = FileUpload1.PostedFile.FileName; // file name with path.

So, how can I open a folder in client PC by C#?

MRWonderFuXker
  • 203
  • 3
  • 19
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – sujith karivelil Jan 24 '17 at 03:20
  • As the answer below correctly states, this is not possible, but can I ask - why do you want to do this (even if you could) ? If your page lets users upload a document using the control, you're going to store the file somewhere in the website's file system - yes ? Why do you want to open the folder the original document is stored in on the client ? – sh1rts Jan 24 '17 at 03:26
  • What you trying to do is done by uploading the file to the server, the part you can do with the user and then giving the user a url/web link to the uploaded file that they can click on and view in the browser – Brian Ogden Jan 24 '17 at 03:27
  • @sh1rts I am thinking maybe the OP thinks that is how other websites/web apps do it maybe... – Brian Ogden Jan 24 '17 at 03:28

1 Answers1

2

For security reasons, browsers do not expose the local filesystem to the Javascript sandbox. What you're asking is not possible with Javascript or any other common browser technology that does not require a client install (like Flash or ActiveX). You definitely cannot get it in c# which runs on the server and has no knowledge of the client's filesystem.

Community
  • 1
  • 1
John Wu
  • 50,556
  • 8
  • 44
  • 80