I am using spire library to read a word file in winform in c#.
here is my code:
Document mydoc = new Document();
mydoc.LoadFromFile(@"C:\Users\user\documents\visual studio 2015\Projects\FormsPrint\FormsPrint\word\1.docx");
but this address is not relative. the problem is I can't move this app to other computers because of its absolute address.
I changed my code to:
Document mydoc = new Document();
mydoc.LoadFromFile(@"\word\1.docx");
but it didn't work again. I used ~/ at first of address but didn't work too. note that the function "loadfromfile"
is one of spire library functions that gets a string path for input. how can I use relative path? I read other questions and answers like this but didn't work for me. how can I change this address to the relative address?
You may need to have the word
folder same location where your .exe
is:
then, call it as
mydoc.LoadFromFile(@"word\1.docx");