3

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.

vahdet
  • 6,357
  • 9
  • 51
  • 106
  • Duplicate of https://stackoverflow.com/questions/24909022/can-i-save-adefault-desktop-path – Ido H Levi Apr 04 '19 at 07:33
  • Do you want access client desktop file from your Web Application ? – Umair Anwaar Apr 04 '19 at 07:42
  • From digging around in the internet for a while and seeing the reference link it seems that since this code is running from server side its is not possible to access client side files, hence I think I must ask user to provide file path. Or is there any other way? – Dhivakhar Venkatachalam Apr 04 '19 at 07:43
  • @DhivakharVenkatachalam that's what my answer suggest, code you have suggested will run on wen server process not on the client side, thus you need a different mechanism to deal with the client side file processing – Mrinal Kamboj Apr 04 '19 at 07:46

1 Answers1

1

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

Mrinal Kamboj
  • 11,300
  • 5
  • 40
  • 74