|
Hello Vineesh,
Trh using the given code snippet. You need to import the namespace System.IO.
using System.IO;
BEGIN CODE
<br />
StreamReader sr = new StreamReader("C:\\Test.txt");<br />
String str;<br />
<br />
str = sr.ReadToEnd();<br />
<br />
int index= str.LastIndexOf("exit 1");<br />
<br />
TextBox1.Text=str.Substring(0,index);<br />
END CODE
I hope this will meet your requirement.
Regards,
Allen
Allen Smith
ComponentOne LLC
www.componentone.com
|
|
|
|
|
hi,
File.ReadAllBytes returns a byte array which can be then used the way you want to play with it.
Regards.
Atif Ali Bhatti.
|
|
|
|
|
Thanks .. It works
vineesh
|
|
|
|
|
i have problems like this. i cannot close forms in tabpage when i clear tabpage. i found this code but it doesnt work absaloutly. that code close only forms in fisrt tabpage but not in others tabpages(for exmp. tabpage2, tabpage3, etc.)
code is that:
List<Form> forms = new List<Form>();
foreach (Form f in Application.OpenForms)
if (f.Handle != Form1.ActiveForm.Handle)
forms.Add(f);
foreach (Form f in forms)
f.Close();
|
|
|
|
|
You want to close forms that are embedded inside tabs ? Isn't that counterintuitive ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
to close all forms that embedded in tabpage more. how can i do?
i can close only one form but i want all form close which opened.
|
|
|
|
|
to close all forms that embedded in tabpage more. how can i do?
i can close only one form but i want all form close which opened.
|
|
|
|
|
I'm trying to develop a forumn page like code project's. The client-side expand and collapse function is what is attractive to me. I've noticed the main property that makes the client-side code work is that all hyperlink ID's are set to the name: id=DynMessLink.
The problem is that asp hyperlink IDs cannot be the same name but I need the databinding functionality for setting the text property.
Any ideas?
"Make it as simple as possible, but no simpler" Issac Newton
|
|
|
|
|
Emit a javascript array with all the id's, pass that to the client-side code.
|
|
|
|
|
In my application I have an array of custom objects that I want to search by one of the properties of the custom object (the ID property which is an int), please see the code below to understand what I'm trying to do:
private CustomObject[] _customObjects;
public CustomObject CustomObjects
{
get
{
if(_customObjects == null)
{
CustomObject[] customObjects = CustomObject.GetCustomObjects();
Array.Sort(customObjects);
_customObjects = customObjects;
}
}
public IsIDInList(int id)
{
return Array.BinarySearch(CustomObjects, id) >= 0;
}
I could use a dictionary of course but I don't want to for some reasons specific to my application. Any suggestions are highly appreciated...
|
|
|
|
|
Hi,
I suggest you have a look at this overload:
Array.BinarySearch Method (Array, Int32, Int32, Object, IComparer)
and if necessary read up on IComparer.
|
|
|
|
|
Hi, thanks for your reply, actually I know about IComparer and IComparable and I use them very often in my code but I never had the need to compare objects of different types, this is why I'm a little confused, I know it's not possible using the generic version of IComparer, are you referring to the non-generic version? A short code sample would very helpful, thanks a lot.
|
|
|
|
|
All your objects are of type CustomObject, aren't they? (either directly or by inheritance)
If you can Sort the Array, why wouldn't you be able to BinarySearch it?
|
|
|
|
|
Hmm, seems you didn't read my post very carefully , I have an array of CustomObject objects, CustomObject has a property named ID which is an int, I want to search the array for a custom object with that ID or in other words I want to be able to know whether there's a CustomObject in the array with that ID, I'm not interested in returning the object, I just want to know whether it's in the array or not.
Regards
|
|
|
|
|
Array.BinarySearch will look for an element with a specific Property, provided your
IComparer is based on that same Property, hence the Array must be Sorted accordingly.
And it will return a positive index when found, or a negative number when not found.
|
|
|
|
|
I only have the value of the ID property (have a look on the code), I don't have the object, can I pass objects of different types to IComparer.Compare()?
|
|
|
|
|
Hi,
if your IComparer only looks at the object's ID, you could pass it a dummy object with the
ID value you are looking for.
|
|
|
|
|
Hmm, so this means to create an object and assign it the value I want for the ID just for the sake of passing to the IComparer, is my understanding correct? So, as far as I can see, comparing objects of different types is not directly supported by the framework, is this correct?
|
|
|
|
|
Waleed Eissa wrote: to create an object and assign it the value I want for the ID
that was the idea yes
Waleed Eissa wrote: comparing objects of different types is not directly supported
objects of different types are different by definition, no need to compare them.
this is not related to any framework, they differ by definition in OO. chairs aren't tables.
If your different types have a useful common ancestor (say furniture) you should
use that as the basis for your logic.
|
|
|
|
|
How do you divide an image? Say i have a 64x64 pixel image and i want to divide this into two equal and separate triangles (triangle1 U triange2 = original image). I was thinking of using points to create regions. Since the image has four corners that i can use as four starting points, i can choose three of them to "bound" a region. Is this possible? If so could someone provide some sample code?
|
|
|
|
|
No bitmap is ever a triangle. Do you want to create bitmaps that each contain a triangle ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
|
Your only other option is a byte array that cannot be displayed until you put it in a bitmap. All bitmaps are square. That's why I'm trying to clarify what you need here.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
So then if i want to create a bitmap that contains a triangle, would I create a bitmap that can enclose the triangle and fill the rest with something like null pixel value?
|
|
|
|
|
No such thing as null, you'd need to choose a color to fill the rest with.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|