Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从ASP.NET中的文件路径获取文件并将文件返回到客户端_C#_Asp.net Mvc - Fatal编程技术网

C# 如何从ASP.NET中的文件路径获取文件并将文件返回到客户端

C# 如何从ASP.NET中的文件路径获取文件并将文件返回到客户端,c#,asp.net-mvc,C#,Asp.net Mvc,我是ASP.NET的新手。我需要有关如何从特定位置获取文件并通过action controller发送到客户端的帮助 从我可以使用的服务器向客户端发送任何文件 var fileBytes = System.IO.File.ReadAllBytes(inkFormulation.DocumentPath); var ext = ImageFormat.Jpeg;// the file extension you want to use return

我是ASP.NET的新手。我需要有关如何从特定位置获取文件并通过action controller发送到客户端的帮助

从我可以使用的服务器向客户端发送任何文件

        var fileBytes = System.IO.File.ReadAllBytes(inkFormulation.DocumentPath);
        var ext = ImageFormat.Jpeg;// the file extension you want to use 
        return base.File(fileBytes, $"image/{ext}", $"SampleImage.{ext}");

这是图像文件。您可以发送具有特定文件扩展名的任何文件

控制器可以返回
FileResult
,如果您希望客户端下载文件,请选中returning
FileResult
,请参阅