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

Free Support Forum - aspose.com

Conveting multiple doc- docx files from one folder

Hey,

I would like to know if it is possible to convert all doc and docx files (don’t know names) from one folder and transfer them to the other folder as a PDF format. Not one PDF but multiple PDFs. One doc = one PDF and so on.

I was trying the following code. But I get error: "DirectoryNotFoundException was unhandled"
Also, I’m not sure how to to convert doc and docx or even rtf files to pdf.

I used the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Words;
using System.IO;

namespace Aspose
{
class Program
{
static void Main(string[] args)
{
string dir = @“C:\Source”;
string des = @“C:\Destination”;

string[] txts = Directory.GetFiles(dir, “*.rtf”);

foreach (string fileName in txts)
{
Document txt = new Document(fileName);
txt.Save(des, SaveFormat.Pdf);


}

}
}
}

Also sometimes I need to change the name of the file (Optional feature).

Thank you for any help.

Thank you

Hi Lukasz,

Thanks for your inquiry. The DirectoryNotFoundException is thrown when part of a file or directory cannot be found. Please make sure that you are using the correct path.

You can convert Doc, Docx, Rtf, Html
etc files to Pdf file format by using Aspose.Words. You can load file
formats mentioned at following documentation link into Aspose.Words DOM.
http://www.aspose.com/docs/display/wordsnet/LoadFormat+Enumeration

Once you have loaded a file of LoadFormat into Aspose.Words DOM, you can easily render it to Pdf. I would suggest you please read the following article for more details:
http://www.aspose.com/docs/display/wordsnet/How+to++convert+a+document+to+pdf