0
我正在开发ASP.NET Web API 2.2与.NET Framework 4.5.1和C#。在Web API服务器文件系统中保存文件
我想将文件保存在服务器的文件夹中(该文件夹位于运行Web API的同一服务器中)。
这是我的代码:
public class ProductionOrdersController : ApiController
{
private readonly IGenericRepository<PRODUCTION_ORDERS> m_PORepo;
private readonly IGenericRepository<AGGREGATIONS> m_AggRepo;
private readonly IGenericRepository<AGGREGATION_CHILDS> m_AggChRepo;
public ProductionOrdersController(
IGenericRepository<PRODUCTION_ORDERS> repository,
IGenericRepository<AGGREGATIONS> aggRepo,
IGenericRepository<AGGREGATION_CHILDS> aggChRepo)
{
m_PORepo = repository;
m_AggRepo = aggRepo;
m_AggChRepo = aggChRepo;
}
[HttpPut]
public HttpResponseMessage Close(long orderNumber)
{
HttpResponseMessage response = null;
PRODUCTION_ORDERS po = m_PORepo.GetById(orderNumber);
if (po != null)
{
// Generate XML
ProductionOrderReport poReport =
new ProductionOrderReport(m_PORepo, m_AggRepo, m_AggChRepo);
XDocument doc = poReport.GenerateXMLReport(orderNumber);
// Save XML.
}
return response;
}
}
我的问题是,我不知道该怎么做。我在互联网上发现的所有内容都讨论如何上传文件。
我该怎么办?
讽刺的是,[XDocument.Save](https://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.save%28v=vs.110 %29.aspx)就是答案。 – 2015-02-05 13:22:12
我会建议你改用Azure Blob Storage。 – TIKSN 2015-02-05 13:24:30
@TIKSN您现在在这里提出什么*可能*原因? – 2015-02-05 13:25:58