I’m hoping someone can help me with this. I need to import multiple .doc files from Multiple Directories and Subdirectories then write them as the PDF files to other directories.
The simple code below:
Dim doc As Document = New Document(MyDir & "\Document.doc")
doc.Save(MyDir & "document.Doc2pdfSave Out.pdf")
Only uploads one doc file and it needs to be name Document.doc
Then the output PDF is named Document.Doc2pdfSaveOut.pdf
I’ve tried many ways to edit that code to upload multiple files without naming them.
Any help is appreciated, I’ve been looking into this for days.
Thanks for your request. I think the following code should help you to achieve what you need:
// For example you have a directory with sub directories and you need to convert all DOC files
// in these directories to PDF.
string dir = @"C:\Temp\";
// Get all DOC fies in this directory (including subdirectories).
string docs = Directory.GetFiles(dir, "*.doc", SearchOption.AllDirectories);
// Loop through all files and convert them to PDF.
foreach(string fileName in docs)
Document doc = new Document(fileName);
Hope this helps.
Thanks for the quick response and the code looks like it will work great.
I’ll try first thing in the morning!
I see you wrote this in Java, is there an easy was to convert to vb.net?
In the meantime I’m going to work on converting, but just wasn’t sure if you had it already in vb.
Thanks for your request. The code is written in C#. It is very easy to translate it in VB. Here is the same code in VB:
' For example you have a directory with sub directories and you need to convert all DOC files
' in these directories to PDF.
Dim dir As String = "C:\Temp\"
' Get all DOC fies in this directory (including subdirectories).
Dim docs As String() = Directory.GetFiles(dir, "*.doc", SearchOption.AllDirectories)
' Loop through all files and convert them to PDF.
For Each fileName As String In docs
Dim doc As Document = New Document(fileName)
I actually did translate most of it until a different problem arose at work.
Thanks for your quick replies and all you help on this!