简体   繁体   中英

How to get the local desktop path of the users file when the application is hosted from server?

I am trying to run a macro-file that will be present in users desktop via my .net website, hence I would like to know how I can get the path of that macro file in my code and open it.

I am currently using following described code to get the path, and I think that this must be trying to take the path from server computer but I would like to get this from users computer, this particular macro file will open internet explorer and navigate to certain website and download a report to local computer hence I would like this to be run from users side.

string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

Is it possible to get the path automatically or should i get that from user. please provide suggestion.

You are hosting a website, which is using a web server like IIS and the user access the site using a browser like edge, chrome, now the file is in user desktop, so the main question remains,

Does the browser process have the access to the file system of the user

Mostly no, especially not via the call Environment.GetFolderPath(Environment.SpecialFolder.Desktop); , this will be good for running it on hosted sever, where w3p.exe process is accessing the file system with required permissions

For the end user desktop

You need to provide the file dialog box, let user select the file / directory and need to plan to serialize the file to the sever (upload) for doing any processing. You can binary serialize the file using a provider like protobuf, msgpack to achieve the necessary functionality

Code you have provided, is good for for the process where you have direct control, like Console, WPF , which runs on the system under certain permission and thus access the file system for processing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM