|
Hi there.........
I am using text reader to read a text file. I have used the following code:
string str = "C:\\MKS.txt";
TextReader textreader = new StreamReader(str);
string inline = "";
while ((inline = textreader.ReadLine()) != null)
{
if (rtEngData.Text == "")
{
rtEngData.Text = inline;
}
else
{
rtEngData.Text = rtEngData.Text + Environment.NewLine + inline;
}
}
Here in my input file (in this code C:\MKS.Txt), a character ë is used.
(Go to the notepad and type ALT+0235, you will get the character.)
Now when I read this file, for this character it reads '�' .
Please tell me if there is any problem with my code block. or suggest me to get proper character.
Thanks....
Vishal.
|
|
|
|
|
Try replacing your TextReader line with this:
TextReader textreader = new StreamReader(str, Encoding.UTF7);
Note the explicit setting of the Encoding argument
|
|
|
|
|
Hi there....
Thanks for you suggestion. It worked.
The character I used ë is present in arial font. Can you please describe me why to use "UTF7".
Arial is a 1 byte font. So, in my opinion it should work without any encoding.
Thanks.......
Vishal.
|
|
|
|
|
Another useful suggestion is you should use a StringBuilder like:
StreamReader textreader = new StreamReader("C:\\MKS.txt", Encoding.UTF7);
string inline;
StringBuilder sb = new StringBuilder();
while ((inline = textreader.ReadLine()) != null)
{
sb.Append(inline);
sb.Append(Environment.NewLine);
}
rtEngData.Text = sb.ToString();
This will be much more performing.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
You are right, however this isn't optimal either. Since you can easily get the file size, you should create the SB with an initial capacity equal to say 1.5 times that (allowing for the NewLines), so it never has to extend itself (which causes all data to be copied).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
why are you reading a stream yourself?
if you can hold all the data in memory, chances are you can afford to do this too:
string[] lines=File.ReadAllLines(str);
rtEngData.Text=string.Join(Environment.NewLine, lines);
and, depending on what line separators are in the file, maybe
rtEngData.Text=File.ReadAllText(str);
is all you need.
FYI: these File methods also accept an Encoding parameter if you need one.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
ë is part of the ANSI code set; code page 1252.
You do not want to use UTF-7; it has nothing to do with ANSI and will do odd translations of characters.
Use System.Text.Encoding.GetEncoding(1252);
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hello,
I've put a TabControl on a Form and added some buttons to add pages and change the Alignment.
When the Tabcontrol is left aligned (vertical tabs) I'd like it to display only one row of tabs with scroll buttons when it overflows. Just like when its alignment is Top.
private void button1_Click(object sender, EventArgs e)
{
tabControl1.TabPages.Add(new TabPage());
}
private void button2_Click(object sender, EventArgs e)
{
if (tabControl1.Alignment == TabAlignment.Top)
{
tabControl1.Alignment = TabAlignment.Left;
}
else
{
tabControl1.Alignment = TabAlignment.Top;
tabControl1.Multiline = false;
}
}
Any help on this would be sincerely appreciated.
|
|
|
|
|
hi
Increase the height of the Tab control
|
|
|
|
|
Hi Satish,
Thank you for your input but alas your solution doesn't work for me. Maybe I should add a few requirements:
1. Users should be able to add tabpages "ad infinitum".
2. Finally the tabcontrol should be hosted in a toolstrip in a toolstripcontainer. (So it will resize with the screen.)
Actually would I'd like to create is a "Tabstrip control" which can be swung around to dock to any side of the screen, just like a Toolstrip inside a toolstripcontainer.
It works fine when it sits on top or bottom of the screen, but when docked on either left or right side of the screen, i can't get the autoscroll buttons to appear, when the tabs overflow.
|
|
|
|
|
|
Hi
If u get the solution please let me know
|
|
|
|
|
Hi Satish,
Once more thank you very much for your persistence and effort. But this doesn't cut it.
If you change the size of the tabcontrol in your solution to 100,100 you'll see two rows (actually columns) of tabs appear, on the left hand side. I would like it to be one column with a "scroll" button.
Now if you change the alignment of the tabcontrol to "Alignment.Top" you'll see only one row of tabs with a scroll "thing" (left and right arrow) (still with the tabcontrol to size 100,100).
I desperately try to get the same effect when the TabControl's Alignment is set to "Left"
Could /should i try a a collection TabPages in a ToolStrip (via ToolStripControlHost)?
I'd be thankful for any advice.
|
|
|
|
|
hi,
how can the pdf file can be downloaded on to desktop in a folder from web application
|
|
|
|
|
tauras81 wrote: how can the pdf file can be downloaded on to desktop in a folder from web application
Perhaps by writing code to do it? See point #2 in this post[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Does the PDF viewer in the web application, not have a save or save as option?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all!
I am running one exe, and this is shown in the task manager
I dont wanat to kill that process anymore, so i would like to attach that exe process
with any one of the existing process !
pls some one can.... help me !
thanks .
Regards
Jack
|
|
|
|
|
Your query makes no sense. Also, which part of this question has anything to do with C#? Are you wanting to inject your code into another PE file? Are you wanting to create a thread in the context of a different process? You want to terminate an application? JUST WTF?!
Read the guidelines[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Can u describe it what is your problem.
If you can think then I Can.
|
|
|
|
|
I have created a watchdog in C#, which monitors a particular agent
When the user try to kill the agent from the task manager then the Watchdog starts the agent once again
problem:
How to disable or not allow the user to kill that watchdog ?
so i thought of attaching the watchdog with existing process so that the user can not find out, because watch dog does not run with seperate process name.
Example:
When we install Nokia PCSuite 6.84.10.3, it does not run with sperate process rather runs with explorer.
so can we also attach the watchdog with any one of the existing Process.
OR is there any other way to protect killing the watchdog from task manager!
thanks ...
Regards
.....Jack
|
|
|
|
|
|
Please tell me how to store datareader values in a array in windows application.
|
|
|
|
|
Try doing some research[^] before asking a question
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
load()
function load()
{
window.open('http://www.baziran.com')
}
ffdsf
load() <script type="text/javascript">
function load()
{
window.open('http://www.baziran.com')
}
</script>
<b>ffsdfsdfsdfds</b>
|
|
|
|
|
load()
function load()
{
window.open('http://www.baziran.com')
}
ffdsf
load() <script type="text/javascript">
function load()
{
window.open('http://www.baziran.com')
}
</script>
<b
|
|
|
|