|
Hi sandeep
actually i want split the each key value field from that onwards we can convert into any like xml or database.pls send me some sample code to store it as key values
Thanks&Regards
RENU
|
|
|
|
|
Renu
We can do that only you have to think about logic see the code below
<br />
StreamReader streamreader=File.OpenText(Server.MapPath("TextFile.txt"));<br />
while (!streamreader.EndOfStream)<br />
{<br />
string line= streamreader.ReadLine();<br />
string[] values= line.Split(' '); <br />
<br />
}<br />
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
Also each line contains only one key value pair or more ? Why pipe then ?
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
pipe symbol is seperate the each key value pair
Thanks&Regards
RENU
|
|
|
|
|
You could use the StreamReader.ReadLine method to read the file line by line and the String.Split method allows you to split each line according to your needs. Take a look at the documentation of both methods to get examples.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Can anybody please help me with this question ?
Role Based Menu[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
You must learn to exercise some patience. It is bad manners to repose a question shortly after you've posted the original, and yes I do count 17 hours as a short time. You have to understand that people on this site give their time freely, and that they help where they can.
You aren't paying for support, so while your problem may be mind bogglingly urgent to you, it might not even make my top 100 of things to do today. More importantly, help can come from any area of the world so the person who may be able to help you may be doing something else such as sleeping - as hard as it may be for you to believe, some of us do have lives outside the boards.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a question regarding the collection designer.
I have written a class "MyCollection" with ICloneable interface.
public class MyCollection: ICloneable
{
int a1 = 1;
string a2 = "abc";
MyCollection() {}
MyCollection( int _a1 )
{
a1 = _a1;
}
MyCollection( int _a1, string _a2 )
{
a1 = _a1;
a2 = _a2;
}
public object Clone()
{
return new MyCollection(a1, a2);
}
}
and use it in a component "Component1". Inside the Component1, I designed 2 properties, P1 and P2, P1 type is SqlParameter[] and another one P2 type is MyCollection[].
private SqlParameter[] p1;
public SqlParameter[] P1
{
get { return p1; }
set { p1 = value; }
}
private MyCollection[] p2;
public MyCollection[] P2
{
get { return p2; }
set { p2 = value; }
}
When I added the component into my form, I can see P1 and P2 in the property grid. For the P1, I can add the new SqlParameter object without problem. But for the P2, I can add but nothing can be saved. After I reopen the designer, P2 is still null. When I can view the design code directly:
this.component11.P1 = new System.Data.SqlClient.SqlParameter[] {
new System.Data.SqlClient.SqlParameter("", System.Data.SqlDbType.NVarChar),
new System.Data.SqlClient.SqlParameter("", System.Data.SqlDbType.NVarChar, 45)};
The designer only create SqlParameter object for P1. But no code for P2.
I have coded the ICloneable interface. However, is there any I still missed in coding the MyCollection class? Any information are appreciate.
Kenneth.Cheng
|
|
|
|
|
Hi all,
I can solve this by specified "public" to the constructors of the MyCollection. Thanks a lot.
Kenneth.Cheng
|
|
|
|
|
BUG1)
Prefer IClonable<t>. It does not exist, you can create one. Or use mine below:
interface IClonable<t>
{
T Clone();
}
BUG2)
Change:
public object Clone()
{
return new MyCollection(a1, a2);
}
TO
public object Clone()
{
return new MyCollection(a1, (string)a2.Clone());
}
because string is NOT a value type and the same refernce exists in each clone not the copy if you do it your way. So if you change the string in ony clone it is also changed for the other clones
BUG3) Never return arrays from Properties, use Collection or better Collection<t> where possible without a set accessor. You can still add items to a Collection or Collection<t> without set accessor.
Hope it helps...
|
|
|
|
|
Please tell me the difference of...OLEDB vs SQLClient..which one is better and why?
Sujit
|
|
|
|
|
SqlClient is optimized for SQL Server, so if you're using SQL Server (and you should) use SqlClient.
Use OleDb if you're using Access (you shouldn't).
MySql, Oracle, and Ingres (and others?) have their own classes, use them as appropriate.
Now stop cross-posting.
|
|
|
|
|
plz tell why i will use SQLClient..what is the advantage of SQLClient..i want to know ths?
Thanks in advance.
Sujit
|
|
|
|
|
HI Friends,
I am trying to match the value from database with checkbox list items and if matched I want to check the checkbox:
if(chklstGroups.Items[i].ToString() == objGroups.Title)
{
chklstGroups.SetItemChecked(i,true); // Method 1 -- Generates Error
chklstGroups.SelectedValue = i; // Method 2 -- No Error but no result.
chklstGroups.SetSelected(i,true); // Method 3 -- No Error but no result.
break;
}
Please help me if you know the solution.
Regards,
Sushant Duggal.
|
|
|
|
|
Wouldn't it be something like:
chklstGroups.Items[i].Checked=true; ?
The day has been too long, I've spent frittered too much time on here today, I need sleep.
-- modified at 2:25 Thursday 3rd May, 2007
This worked for me:
this.checkedListBox1.SetItemChecked(0,true) ;
|
|
|
|
|
Sushant Duggal wrote: chklstGroups.SetItemChecked(i,true); // Method 1 -- Generates Error
What sort of error?
-- modified at 2:41 Thursday 3rd May, 2007
More information required.
|
|
|
|
|
Object reference not set.
Sushant Duggal.
|
|
|
|
|
Then I suppose your chklstGroups hasn't been set.
Show more of the code.
|
|
|
|
|
Use debugger to check whether the "if" statement evaluates to true
by creating breakpoint at a line inside the if block.
Regards,
Arun Kumar.A
|
|
|
|
|
I no longer use CheckedListBox es, I use TreeView s that look like CheckedListBox es; they're much more advanced.
|
|
|
|
|
try this:
if( (objGroups.Title != null || objGroups.Title != DBNull) && chklstGroups.Items[i].ToString() == objGroups.Title.ToString())
{
chklstGroups.SetItemChecked(i,true); // Method 1 -- Generates Error
chklstGroups.SelectedValue = i; // Method 2 -- No Error but no result.
chklstGroups.SetSelected(i,true); // Method 3 -- No Error but no result.
break;
}
Hope it helps...
|
|
|
|
|
Hi,
For a folder i have to set the permission as full control by programmatically,im using C#.Net 2003,How can i accomplish this one,plz help me..
Rgrds
Kanna..
|
|
|
|
|
Try the following.
//Add these namespaces to your page.
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
//Put this code in either Page_Load or any other function
string DirectoryName = @"C:\Test"; //Make sure the directory exists.
string Account = @"Domain\username"; //Replace it with your Domain Name and User Name.
DirectoryInfo dInfo = new DirectoryInfo(DirectoryName);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(Account, FileSystemRights.FullControl, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
Hope it helps!
Pranav
|
|
|
|
|
Hi,
Thanks for your reply..But i couln't get this namespace
using System.Security.AccessControl;
Is i want to refer any namespaces for this one?im using framework version is 1.1.4322,for this which namespaces i have to refer..plz tell me..
rgrds
Kanna..
|
|
|
|
|
This namespace is specific to .Net 2.0
I will try to write code which works for 1.1.
Thanks,
Pranav
|
|
|
|