Hi All,
I have got the following error when I was trying to do some operations with a word file.
This File could not be found. (C:\//Users/rahul raj/AppData/Loc......).
The following code caused exception...
textBox1.Text = @"C:/Users/rahul raj/AppData/Local/Temp/ConsultantResumes/PROGRAMMER_NAVEEN.doc";
textBox2.Text = @"E:\Ace Logic\Consultrak\Resumes\PROGRAMMER_NAVEEN.doc";
Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object originalFileName = textBox1.Text;
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
object destinationName = textBox2.Text ;
try
{
Microsoft.Office.Interop.Word.Document openDocument = WordApp.Documents.Open(ref originalFileName, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
openDocument.SaveAs(ref destinationName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
((Microsoft.Office.Interop.Word._Document)openDocument).Close(ref missing, ref missing, ref missing);
((Microsoft.Office.Interop.Word._Application)WordApp).Quit(ref missing, ref missing, ref missing);
System.Windows.Forms.MessageBox.Show("Finished", "AddTo - Test");
}
catch (Exception Ex)
{
System.Windows.Forms.MessageBox.Show(Ex.Message.ToString(), "AddTo - Test");
}
Can someone help me to solve this issue?
I have solved this problem by simply changing /
here is the code...
if (textBox1.Text.ToString().Contains("/"))
{
textBox1.Text = textBox1.Text.Replace("/", "\\");
}
Regards
Sebastian