Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jun 05, 2017 2:45 pm

Hello, i'm trying to replace a text in word document with another text using replace method but it gives {"Current file path is not exits."} error.
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Spire.Doc;

   
namespace WindowsFormsApplication6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
       
        private void button1_Click(object sender, EventArgs e)
        {

            //load
            Document doc = new Document();
            doc.LoadFromFile(@"‪‪‪E:\asdaa.docx");

            //save
       
            doc.Replace("Text1", textBox1.Text, false, true);
            doc.Replace("Book", textBox2.Text, false, true);
            doc.SaveToFile(@"C:\Users\kchkholaria\Desktop\asdaa.docx", FileFormat.Docx);

             
           

        }
    }
}

Any advice would be helpful
thank you in advance.

kotechkh
 
Posts: 6
Joined: Thu Jun 01, 2017 1:56 pm

Tue Jun 06, 2017 1:37 am

Dear kotechkh,

Thanks for your inquiry.
If you are using older version of Spire.Doc, we firstly suggest upgrading to the latest Spire.Doc Pack(hot fix) Version:5.9.16. Hope this helps. After trying this version, if the problem persists, please provide us with your input document here, or send it to us(Support@e-iceblue.com) via email.That would be helpful to investigate this issue.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Jun 07, 2017 9:28 am

Dear kotechkh,

Has your issue been resolved ?
Could you please give us some feedback at your convenience ?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sun Jul 02, 2017 11:31 am

Thank you very much I fixed the problem somehow but It wasn't a spire.doc version problem.

kotechkh
 
Posts: 6
Joined: Thu Jun 01, 2017 1:56 pm

Mon Jul 03, 2017 1:19 am

Dear kotechkh,

Thanks for your feedback.
Please feel free to contact us if you need any help.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Sep 07, 2022 1:50 pm

kotechkh wrote:Thank you very much I fixed the problem somehow but It wasn't a spire.doc version problem.


i have same issue , please tell me how do you solve this problem, thank you very much..

kasimdmr
 
Posts: 6
Joined: Thu Mar 15, 2018 11:04 am

Thu Sep 08, 2022 7:15 am

Hello,

Thanks for your inquiry.
Please make sure your file path and filename are correct and the file can be accessed. Do you miss any single letter? Such as “.doc” and “.docx”. If the filename and file path are all correct, please offer the following message to help us reproduce your issue and work out a solution for you, thanks for your assistance in advance.
1) Your input file.
2) Your test code that can reproduce your issue.
3) The product version you used, such as Spire.Doc10.7.16.
4) Application type, such as Console App, .NET Framework 4.8.
5) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
For the above info, you can leave message here, or send them to us vis email
(Support@e-iceblue.com).

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Thu Sep 08, 2022 1:32 pm

Abel.He wrote:Hello,

Thanks for your inquiry.
Please make sure your file path and filename are correct and the file can be accessed. Do you miss any single letter? Such as “.doc” and “.docx”. If the filename and file path are all correct, please offer the following message to help us reproduce your issue and work out a solution for you, thanks for your assistance in advance.
1) Your input file.
2) Your test code that can reproduce your issue.
3) The product version you used, such as Spire.Doc10.7.16.
4) Application type, such as Console App, .NET Framework 4.8.
5) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
For the above info, you can leave message here, or send them to us vis email
(Support@e-iceblue.com).

Sincerely
Abel
E-iceblue support team



thank you very much i finded solution.
problem is not irrelevant with spire.doc.

i write code to get working directory:
it s this :System.Web.HttpContext.Current.Server.MapPath("~")
this code get working directory with "\" char in local computer but when i deploy it to server it gets directory without "\" char so it gives exception when try to reach document.
so i use "PhysicalApplicationPath" to get same directory with "\" in local computer and server.
so problem is solved.

System.Web.HttpContext.Current.Request.PhysicalApplicationPath

kasimdmr
 
Posts: 6
Joined: Thu Mar 15, 2018 11:04 am

Fri Sep 09, 2022 2:12 am

Hello,

Thank you for sharing your solution. If you have any issue in the future, just feel free to conatct us. Hope you have a nice day! :)

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc