Decard
Decard

Reputation: 57

c# How to open a Word file and set the path is relative to the project folder

Word.Application ap = new Word.Application();
Document document = ap.Documents.Open(@"export.doc");
ap.Visible = true;

I try this, but i need set the path is relative to the project folder

Upvotes: 0

Views: 835

Answers (1)

NicoRiff
NicoRiff

Reputation: 4883

You can use Application.StartupPath:

Word.Application ap = new Word.Application();
Document document = ap.Documents.Open(Application.StartupPath + @"\export.doc");
ap.Visible = true;

Upvotes: 1

Related Questions