We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Question about doc.Save(MemoryStream- Aspose.Word.SaveFormat)

I am creating a Word document on the server and trying to save it to a particular spot on the server, but honestly, i have no clue how to do this. Can someone suggest something?

This code was given to me by one of the Aspose developers, and it works great, i just dont know how to tell it to save the MemoryStream to c:\test\someFile.doc

System.Guid guid = System.Guid.NewGuid();

String strGuid = guid.ToString();

Aspose.Word.Document doc = new Aspose.Word.Document();

Aspose.Word.DocumentBuilder builder = new Aspose.Word.DocumentBuilder(doc);

for (int i = 0; i < 10000; i++)

{

builder.Writeln("This is line of text.");

}

String strFilePath = @\\server\ + strGuid;

System.IO.Directory.CreateDirectory(strFilePath);

MemoryStream docStream = new MemoryStream(strFilePath + @"\someFile.doc");

doc.Save(docStream, Aspose.Word.SaveFormat.FormatDocument);

J

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you should create subfolder in the root folder of your web application and store all documents there. Then you can save documents in this folder using Server.MapPath. For example see the following code:

Doc.Save(Server.MapPath(@"documents/mydoc.doc"));

Hope this helps.

Best regards.

Thanks again for the quick answers alexey.