|
There are a couple of things strange in your code.
1- You assign a BinaryReader but you do not use it.
2- You are writing a bunch of bytes to a MemoryStream. Are you just trying to copy the 2 byte arrays to a single file (if not, what your code is doing totally escapes me)? This is not really needed. Try this instead:
FileStream fs = File.Create(@"C:\text.doc");
fs.Write(unicodebytes, 0, unicodebytes.Length);
fs.Write(unicodebytes1, 0, unicodebytes1.Length);
fs.Flush();
fs.Close();
If this is not the case, please explain what you are trying to do.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
thanks for your help but I have the same problem.
I can see the first file but I can't see the second.
I want to copy 2 documents files in one file.
|
|
|
|
|
Did you try to run it through a debugger? is it possible that unicodebytes1 is empty?
Make sure your 2 byte arrays actually contain the bytes.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
thanks for your help.
The size of my new created file is equal with the size of the first file + the size of the second file.
The unicodebytes1 is not null.
thanks again.
|
|
|
|
|
Combining 2 word documents by appending one to the other will never work. Your barking up the wrong tree.
|
|
|
|
|
If your trying to combine 2 wrod doc's it's not that simple.
Word docs use Structured Storage[^] (aka DocFile[^]) for pre 2007 files.
For 2007 there is a new XML format ... you can do your own google for that :P
Either way you cannot simply concatenate these documents.
|
|
|
|
|
thanks for all your help.
I found how to resolve my problem(with tx textcontrol).
Thanks again.
Regards,
WhiteGirl23
|
|
|
|
|
I have a list box with some items.
my code snippet:
foreach(string item in listbox1.items)
{
// some code
}
it gaives an exception:
Unable to cast object of type 'System.Drawing.Point' to type 'System.String'.
which is in the first line i.e string item
help me with an alternative way
|
|
|
|
|
listbox1.items returns a ListItemCollection (you must use System.Collections), it doesn't return a string array.
foreach(ListItem item in listbox1.items)
{
string sText = item.Text;
string sValue = item.Value;
// some code
}
Regards.
Just call me Valy...
|
|
|
|
|
Thanks for the suggestion...
But when I use
foreach(ListItem item in listbox1.items)
{
}
It throws an exception saying ListItem is not a type or namespace
are u missing a assembly reference or an using directive
|
|
|
|
|
sangramkp wrote: are u missing a assembly reference or an using directive
Well, Are you?
ListItem is in the System.Web.UI.WebControls namespace. It is probably the 'using' you are missing rather than the assembly reference.
|
|
|
|
|
But I am working on windows Application...
|
|
|
|
|
But i am working on a windows forms application
|
|
|
|
|
Hi,
a ListBox item can have any type you choose, all the items in a ListBox
dont even have to have the same type.
Foreach insists that each item in the collection has the indicated type,
otherwise an Exception will be trown.
If the types differ and you want to process only one of the types, say you
only want to process the strings, then do the following:
foreach (object item in collection) {
string str=item as string;
if (str!=null) {
.. handle the str
}
}
|
|
|
|
|
Hi pattyn
While i am trying to use
foreach(ListItem item in listbox1.Items)
{
}
It shows an error:
Error 1 The type or namespace name 'ListItem' could not be found (are you missing a using directive or an assembly reference?)
|
|
|
|
|
So ?
I never told you to use the ListItem class, did I ?
|
|
|
|
|
I really like your sig XD
|
|
|
|
|
Thanks.
I devised it to encourage people to search CodeProject before asking
simple questions for which the answers are readily available...
|
|
|
|
|
Except it hasn't worked in this case
only two letters away from being an asset
|
|
|
|
|
Yeah, what would we do without simple questions ?
We would have to investigate the hard ones !?
|
|
|
|
|
Hi,
I am trying to insert selected items from a listbox into a label, the listbox is fillby a database query, the problem is all I get is this System.Data.DataRowView it works fine when I dont use a database query and just text in the listbox.
Cant anyone help on a solution for this??
Dim i As Integer<br />
For i = 0 To ListBoxUpgrade.Items.Count - 1<br />
If ListBoxUpgrade.Items(i) Then<br />
LabelSum.Text = LabelSum.Text & Space(6) & ListBoxUpgrade.SelectedItem(i) & vbCrLf<br />
End If<br />
Next i
Thanks in advance!
Stefan.
"All answers have a question? All code has an end."
|
|
|
|
|
I don't use VB very much but from what I know in C# if you use something like
ListBox1.SelectedItem[i] it would not work.
ListBox1.SelectedItem[i] returns a ListItem this one has a Text and a Value property.
I think you should use something like ListBoxUpgrade.SelectedItem(i).Text
Hope it helps...
Just call me Valy...
|
|
|
|
|
You must select a column index for the DataRowView. Try this:
<br />
for(int i=0; i<ListBoxUpgrade.Items.Count-1; i++) {<br />
if(ListBoxUpgrade.Items[i].IsSelected) {<br />
LabelSum.Text += " " + ((DataRowView)ListBoxUpgrade.SelectedItem[i])[yourIndex] + "\r\n";<br />
}<br />
}<br />
____________________________________
There is no proof for this sentence.
|
|
|
|
|
you would be better of posting this in the VB forum instead of the C# forum...
|
|
|
|
|
Thanks,
Sorry I thought I had!
My bad.
"All answers have a question? All code has an end."
|
|
|
|