English 中文(简体)
如何将随身阵列转换成适当的档案格式。 NET MVC
原标题:How to convert byte array into it s appropriate file format in ASP.NET MVC

我有一个制度,可以把一个旁观阵列(不了解其pdf、txt或 doc)提供给我的可下载档案。 如今,通常在伙伴关系中。 NET MVC 我希望这样做。

return File(labTestResult.File, "application/pdf");

之所以容易,是因为我知道档案类型是什么。 既然档案类型可能是什么,那么能否将档案下载到适当的格式?

问题回答

Asp.net MVC非常容易,因此,如果你需要以不同的方式在答复中发出任何信息,即你可以撰写一份行动说明,供你使用,而不必具体说明奇梅类型,但确实不建议这样做。

使用 问题,从头条 by中获取玉米。

如果你也能够确定使用该守则的习俗行动结果,那么你的控制器代码就成为:return AutoMimeFile(labResult.File);

我确信,这样做确实是好的。 某些档案格式有“磁号”,可查到:Here,用于更多这方面的信息。 我从未亲自尝试过,因此,我可以说,这种执行将多么坚实。 我认为最好的方法是用数据检索文档类型。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签