我正在使用filestream
来编写文本文档。除了将文档导向到错误的文件夹之外,一切看起来都很好。如何在编写.txt文档时更改文件夹位置的路径?
这是代码认为它应该创建文档:
C:\Users\user2\Desktop\work\SuperBy\nop\NopCommerceStore\Administration\FedEx
的FedEx
文件夹不到风度存在于管理文件夹。但是,如果我创建一个FedEx
文件夹并将其放入Administration
文件夹中,则会相应地显示.txt
文档。
这是实际的路径就在该文件应该被写入该文件夹:
C:\Users\user2\Desktop\work\SuperBy\nop\NopCommerceStore\FedEx
我根本不明白的代码是如何工作的,以及如何去改变它,真的需要一些帮助与此有关。
try
{
Order o = IoC.Resolve<IOrderService>().GetOrderById(orderID);
Customer ThisCustomer = o.Customer;
// Specify file, instructions, and privelegdes
string path = System.Web.HttpContext.Current.Request.PhysicalPath;
int index = path.LastIndexOf("\\");
string realPath = path.Substring(0, index + 1);
FileStream file = new FileStream(realPath + "/FedEx/" + orderID.ToString() + ".txt", FileMode.OpenOrCreate, FileAccess.Write);
}
realPath +“/../FedEx/”可能有帮助 –
谢谢Thomas! – koffe14