2

I'm developing a web application using MVC which is hosted in web server. Whenever a user accesses the application, it has to fetch the local app data folder from the clients machine.

Is there any possible way to achieve the above mentioned scenario?

I have tried using Environment.Specialfolder, but it is giving the path of web servers local data not the path of client's machine

C# :

string s = Environment.GetFolderPath(
            Environment.SpecialFolder.LocalApplicationData);
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Veda Sri
  • 31
  • 5

1 Answers1

3

Server-side code cannot just access files on client's machine. Instead, this functionality should be implemented with client-side scripts.

If you need to let your app persist some data or file on user's machine, and later read that data and send it to the server (or use it on the client), you have plenty of options in the modern browsers:

Fetching an arbitrary file from user's machine is a totally different story, because it has security implications. Here your options are:

  • Put <input type="file"> on a page and let the user pick a file that will be uploaded to the server.
  • Use HTML Drag & Drop to let user drag a file onto your page
  • Develop an accompanying desktop application, which the users will have to install on their machines.
  • You may also explore the possibility of developing a browser extension, though this will give you very limited access to user's file system, AFAIK. Today the major standards are Web Extensions for mainstream browsers, and Browser Helper Objects for Internet Explorer.
felix-b
  • 8,178
  • 1
  • 26
  • 36
  • Thanks for your reply Felix. I'm trying to access cookies file stored in user's system.Can you help in achieving that. – Veda Sri Jun 04 '19 at 12:22