Write a file to desktop of current user in C# asp.net
-
05-07-2019 - |
Question
if i have this code, this creates a problems if other user that dont have acces to the network share tryes to run the method. How can i make this method write the file to the current users desktop?
private void skriveTilFil()
{
StreamWriter writer = new StreamWriter(@"\\192.168.1.2\tmp\script.vbs");
writer.WriteLine(scripttbx.Text);
writer.Dispose();
}
Solution
You can do it in an intranet environment by altering permissions/policies. You have to give the appropriate permissions to your ASP.NET application through IIS/Active Directory to the shares.
OTHER TIPS
On client/server web environments, you shouldn't be able to write data directly on client machines.
Can you download some data to your browser and/or run an ActiveXObject installed on client workstation? This can lead to some issues installing components on users machines, but will be more easily developed.
Browser security prevents this without using a control such as an ActiveX.
Any particular reason you don't just provide a download link?