|
Easily done, at least it's fixed!
|
|
|
|
|
hi!
IHi
i want to merge two or more text files.i.e. the content of the second file has to append to the content of the first file.
e.g. abc.doc, ab.doc and xyz.doc i want all three files merged in abc.doc
give me idea , how can i do this.
thanx with regards,
modified on Wednesday, October 6, 2010 12:52 AM
|
|
|
|
|
You can use FileStream for that.
rahul
|
|
|
|
|
Word Files? ... Good Joke
|
|
|
|
|
No, you can't. You'll be screwing up the content of the second file because you just appended all the Word headers and data (before the content) to the end of the first document, which Word will not expect.
|
|
|
|
|
|
This may come as a surprise, however a Word document is not a text file; it is a complex file that, to all intents and purposes, contains text, but also graphics and images, formatting, page layout information, table of contents, headers and footers, foot notes, possibly revision information, and lots more. You can't concatenate two of those, only a very Word-savvy user can, and he would have to make some tough choices while doing so.
|
|
|
|
|
When you say merged, what do you mean? Do you just want the documents appended to each other? What I would do, if I were you, would be to use word automation to open abc.doc and then the other two files; use select all and copy from the other two documents, and move to end and paste in abc.doc.
|
|
|
|
|
hi
Can u please tell me the real life example for the begin init and end init utilization in datatable and in which situation it should be used.
Thanks
|
|
|
|
|
If you want to change multiple properties of the DataView object but don’t want the changes to affect the data visible through the DataView until you’ve changed all of the desired properties, you can use the BeginInit and EndInit methods.
For example, say you have a DataView bound to a particular DataTable and you’ve also set the DataView object’s RowFilter property so that only a small fraction of the rows are visible through the DataView. You’re displaying the contents of the DataView on a Windows form using a DataGrid, and based on input from the user you want to change the settings of the DataView object’s Table and RowFilter properties. In this situation, you should enclose the code that changes the DataView object’s properties within calls to the DataView object’s BeginInit and EndInit property to prevent the DataGrid from momentarily displaying all rows from the new DataTable.
http://www.koopoo.cn/ASPNET/ADONET/adonethtml/32ch10f.htm[^]
rahul
|
|
|
|
|
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:
public string GetWebText()
{
byte[] data;
mshtml.HTMLDocumentClass ms;
string strHTML;
mshtml.IHTMLDocument2 objMyDoc;
string innerText;
TextWriter tw;
FileInfo fi;
int count = 0;
Encoding curEncoding = Encoding.GetEncoding(1256);
string htmlEncodingString = null;
CookiedWebClient wc = new CookiedWebClient();
fileName = path + curLangStr +".txt";
FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
tw = new StreamWriter(ostrm, curEncoding);
int j = 0;
try
{
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
}
}
catch (Exception e)
{
Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
tw.Close();
wc.Dispose();
}
return "";
}
modified on Tuesday, October 5, 2010 5:08 PM
|
|
|
|
|
I'm not seeing things well here, you really should show formatted code, using PRE tags. However it seems
Meneedhelp wrote: objMyDoc.write(strHTML);
is not taking any encoding into account.
|
|
|
|
|
I am not sure I understand.
objMyDoc is mshtml.IHTMLDocument2 object which I am using to extract the body of the HTML text. This text is saved in the string "innerText". It appears correctly to this point. But when I write this text to a .txt file, the text file contains garbled characters.
|
|
|
|
|
I have a piece of code that reads an Arabic http link and copies the html body text to a text file. While debugging, I can see that the arabic text is being read correctly (I see arabic characters) but the output file contains weird characters. Can someone point out to me what I am doing wrong here? Here is relevant part of the code:
public string GetWebText()
{
byte[] data;
mshtml.HTMLDocumentClass ms;
string strHTML;
mshtml.IHTMLDocument2 objMyDoc;
string innerText;
TextWriter tw;
FileInfo fi;
int count = 0;
Encoding curEncoding = Encoding.GetEncoding(1256);
string htmlEncodingString = null;
CookiedWebClient wc = new CookiedWebClient();
fileName = path + curLangStr +".txt";
FileStream ostrm = new FileStream(fileName, FileMode.Create, FileAccess.Write);
tw = new StreamWriter(ostrm, curEncoding);
int j = 0;
try
{
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
}
}
catch (Exception e)
{
Console.WriteLine("Exception message: " + e.Message +" url["+j+"] : "+urlArray[j]);
}
finally
{
tw.Close();
wc.Dispose();
}
return "";
}
|
|
|
|
|
I'm not sure what you are attempting with CookiedWebClient and HTMLDocumentClass. I would suggest you try replacing
data = wc.DownloadData("http://www.alarabonline.org");
ms = new mshtml.HTMLDocumentClass();
strHTML = curEncoding.GetString(data);
objMyDoc = (mshtml.IHTMLDocument2)ms;
objMyDoc.write(strHTML);
innerText = objMyDoc.body.innerText;
tw.Write(innerText);
by
data = wc.DownloadData("http://www.alarabonline.org");
strHTML = curEncoding.GetString(data);
tw.Write(strHTML);
to see how that works out. I expect it will handle Arabic text well.
I am puzzled by you casting an HTMLDocumentClass to IHTMLDocument2; and by the compiler accepting your objMyDoc.write(strHTML) statement, as write expects an array of BSTR, not a string.
I would suggest you try and solve your functional requirement based on System.Windows.Form.HtmlDocument
|
|
|
|
|
Meneedhelp wrote: but the output file contains weird characters.
And how exactly did you 'see' those characters?
In other words you used something to view that file. What did you use? And how did you validate that that method would display the characters correctly in the first place?
|
|
|
|
|
I opened up the txt file which I am writing into.
The method displays characters correctly for Spanish, Italian, Hindi and Thai when I replace the http link and the encoding.
|
|
|
|
|
From my WinForm application I have a need to call javascript function from a WebBroswer control using something like this:
webBrowser1.Document.InvokeScript("show_line",...);
The show_line function is in javascript and looks like this:
function show_line(points)
{
for(var i=0;i<points.length;i++)
{
}
}
In other words, the parameter points is an array. My questions is how to pass an array of double from C# to javascript using
webBrowser1.Document.InvokeScript("show_line", points);
Thanks!
modified on Wednesday, October 6, 2010 11:33 AM
|
|
|
|
|
I'm trying to figure out how to set up the inside vertical & inside horizontal line to be setup as hairline weight.
That's what I have for now to setup the line for inside vertical and inside horizontal.
cellRange = oSheet.get_Range(oSheet.Cells[excelRow + 2, excelColumn + 3], oSheet.Cells[excelRow + 6, excelColumn + 7]);
cellRange.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;
cellRange.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlContinuous;
Question is how do I set up the line weight to be hairline?
-- Modified Tuesday, October 5, 2010 2:59 PM
|
|
|
|
|
Try Excel.XlLineStyle.xlSlantDashDot;
For a list of supported styles, see here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
The line weight is kinda of too thick. I prefer hairline esp for printing.
|
|
|
|
|
now that I've got it!
I inserted a new statment line (see 2nd line)
cellRange = oSheet.get_Range(oSheet.Cells[excelRow + 2, excelColumn + 3], oSheet.Cells[excelRow + 6, excelColumn + 7]);
cellRange.Borders.Weight = Excel.XlBorderWeight.xlHairline;
cellRange.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = Excel.XlLineStyle.xlContinuous;
cellRange.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlContinuous;
|
|
|
|
|
Ok. Thanks for posting the solution.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
using process.start() i opened a .cs file.but i want to set the cursor to a specified line no, is there any way to do this.
thanx in advance.!
|
|
|
|
|
What are you trying to accomplish?
I know the language. I've read a book. - _Madmatt
|
|
|
|