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