Hi guys,
I'm creating a site that allows users to download report files. The files are created at run time based on user selections. I created a folder within the root of my site called "\TempRprts" and what I'm trying to do is (1) save the report file (created based on user criteria) to the "\TempRprts" folder, (2) upload the file to the user's computer using Response.WriteFile, and (3) once the user has download the file to his machine, delete it from the "\TempRprts" folder. I have the following code:
The bold red line above produces the error: Access to the path "c:\inetpub\ is denied. I went ahead and assigned Write permissions to the root folder of my site and also to the c:\inetpub\ folder and I still get the same error. Can anybody tell me what the problem is?
By the way, if I change the folder I'm trying to save the temporary file to from this.MapPath("TempRprts\\" + fileName) to "C:\\" + fileName, everything works fine. But of course, I wouldn't want to use the C drive of my server to write temporary files, or would I?
Can anybody please point me in the right path?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin
I'm creating a site that allows users to download report files. The files are created at run time based on user selections. I created a folder within the root of my site called "\TempRprts" and what I'm trying to do is (1) save the report file (created based on user criteria) to the "\TempRprts" folder, (2) upload the file to the user's computer using Response.WriteFile, and (3) once the user has download the file to his machine, delete it from the "\TempRprts" folder. I have the following code:
Code:
[COLOR=blue]string[/color] fileName = "MyFile.pdf";
[COLOR=blue]string[/color] fileSave = [COLOR=blue]this[/color].MapPath("TempRprts\\" +
fileName);
[COLOR=blue]string[/color] contentString = "attachment; " +
"fileName=\"" + fileName + "\"";
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", contentString);
[b][COLOR=red]Response.WriteFile(fileSave);[/color][/b]
Response.End();
By the way, if I change the folder I'm trying to save the temporary file to from this.MapPath("TempRprts\\" + fileName) to "C:\\" + fileName, everything works fine. But of course, I wouldn't want to use the C drive of my server to write temporary files, or would I?
Can anybody please point me in the right path?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin