简体   繁体   English

将 pdf 文件保存在本地文件夹中或下载

[英]save an pdf file in local folder or downloads

I am using the below code to save an pdf file in the particular folder.我正在使用以下代码将 pdf 文件保存在特定文件夹中。 if the folder is not there it will auto create an folder.如果文件夹不存在,它将自动创建一个文件夹。 It is working fine in local.它在本地运行良好。 But when i publish the website to IIS.但是当我将网站发布到 IIS 时。 it doesnt work.它不起作用。

  string folderPath = "D:\\Labels\\";
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }
                string file = @"D:\Labels\" + DateTime.Today.ToString("dd-MM-yyhh-mm-ss") + ".pdf" + "";
                var fileStream = File.Create(file);
                // change file name for PNG images
                responseStream.CopyTo(fileStream);
                responseStream.Close();
                fileStream.Close();
                ShowMessage("Downloaded Sucessfully", MessageType.Success);

Ι want to save the file in the local who ever use the website

This is not possible - what you can offer is a link to download the file - you can not run the File.这是不可能的——你可以提供一个下载文件的链接——你不能运行File. functions on client from server.来自服务器的客户端功能。

The File. File. functions can work only for server side, and only if you have permissions on the directories.函数只能在服务器端工作,并且只有当您对目录具有权限时。

How to set correct file permissions for ASP.NET on IIS 如何在 IIS 上为 ASP.NET 设置正确的文件权限
file download by calling.ashx page 通过calling.ashx页面下载文件
What is the best way to download file from server 从服务器下载文件的最佳方法是什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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