|
Both are static members. If you use the first method, it will randomly generate the salt characters for you and then call the second method. Salt, in this case, are two letters that are used to provide some extra randomness for the encryption, and allow you to repeat any previous encryption (if you also have the text that was encrypted).
Another thing users should know is that the text to encrypt should not be more then 8 characters long. If your text is longer than 8 characters, only the first 8 are used and the rest is ignored.
|
|
|
|
|
Hi huys
I have small issue, look at my code below:
HttpPostedFile myFile = files.PostedFile;
string strFilename = Path.GetFileName(myFile.FileName);
string[] lines = File.ReadAllLines(strFilename);
foreach (string s in lines)
{
string[] fragments = s.Split(',');
errors.Text += fragments[0] + " ";
errors.Visible = true;
}
The contents of my file look like:
Kiss,Simwaba,morgan@domain.co.za,0743720187,1987/12/31
Person,Simwaba,morgan@domain.co.za,0743720187,1987/12/31
what happens is that when i pick
errors.Text += fragments[0];
it returns "Kiss Person" which are the first index[0]s in both lines.
I just want to retrieve "Kiss" how can I do this?
Please help me in case am making a mistake somewhere.
Morg
|
|
|
|
|
It is concatenating both parts in the loop (underlined)
foreach (string s in lines)
{
string[] fragments = s.Split(',');
errors.Text += fragments[0] + " ";
errors.Visible = true;
}
I'm not sure what you want it to do from there. You either need to create a list of errors and add in turn, or return the error inside the loop if you want to stop processing.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Keith Barrow wrote: errors.Text += fragments[0] + " ";
oh yes I know that, but first when i put:
foreach (string s in lines)
{
string[] fragments = s.Split(',');
errors.Text = fragments[0];
errors.Visible = true;
}
then it will give me the first index[0] in the last line(Person) not (Kiss). File contents:
Kiss,Simwaba,morgan@domain.co.za,0743720187,1987/12/31
Person,Simwaba,morgan@domain.co.za,0743720187,1987/12/31
and if I do this:
foreach (string s in lines)
{
string[] fragments = s.Split(',');
errors.Text += fragments[0];
errors.Visible = true;
}
then it will give me both "Person" and "Kiss". But I only want to retrieve "Kiss"
the first index[0] in the first line.
Do you think am screwing up somewhere?
|
|
|
|
|
Like I said, it's your loop. If you only ever want to process the first line, this is the job:
string[] fragments = lines[0].Split(',');
errors.Text += fragments[0];
errors.Visible = true
I think I'm missing the point, as you must have put the loop in for a reason.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
You are a star man, exactly what I want to do...
Thanks again
|
|
|
|
|
No probs, somtimes the hardest ones to spot are the easiest.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Cool,
hey now another problem is that what if I don't know
the number of lines a file has, how can I deal with this line:
string[] fragments = lines[0].Split(',');
especially if I want to read all the lines of that file
and I don't know how many lines the file has.
Thanks for being helpful man
|
|
|
|
|
The code I posted only reads the first line, and will throw an error if the file is empty
To process the whole file you need the loop. You need to decide how you are going to handle it. The way I see it you have a few realistic options:
- Create a list of errors and add to it in the loop.
- Only register the first error and continue processing.
- Break out of the loop if an error is found.
Which of these apply?
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Cool bro I have figured it out check below:
manager = new data_manager();
HttpPostedFile myFile = files.PostedFile;
string strFilename = Path.GetFileName(myFile.FileName);
if (strFilename != "")
{
string[] lines = File.ReadAllLines(strFilename);
for (int b = 0; b < lines.Length; b++)
{
string[] fragments = lines[b].Split(',');
int count = lines.Length;
errors.Text = fragments[0] + count.ToString();
errors.Visible = true;
string first = fragments[0]; string last = fragments[1]; string email = fragments[2];
string phone = fragments[3]; string birth = fragments[4];
string addrecord = manager.AddContact(first, last, email, phone, birth, Request.QueryString["userid"]);
if (addrecord == "done")
{
error.Text = "Contact added check in the table below!";
error.Visible = true;
FillContacts(Request.QueryString["userid"]);
}
else
{
error.Text = addrecord;
error.Visible = true;
}
}
}
else
{
errors.Text = "No file with content was selected";
errors.Visible = true;
}
and this works quiet well....super!
|
|
|
|
|
You use indexof and substring function to retrieve only "Kiss".
foreach (string s in lines)
{
int i = s.indexof(',');
string sub = s.substring(0,i);
}
|
|
|
|
|
Because that is far more succinct than he currently has. Also, when he needs to process other elements your code should much easier to do than in than his own. Oh, hang on everything, except this sentence) is a whopping lie.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
i just give him answer. I think i forgot to remove foreach loop....
|
|
|
|
|
Actually, it looks more like the thing you needed to change you didn't and vice versa.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
hmmmmmm k i ll. Any way wat succit..
|
|
|
|
|
Uni-Vote all you like, my rep'll take it
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Nope. I've run that through every possible combination of Google Translate and it keeps coming back with the same response: You're a dribbling idiot.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Bad news for you mate. Under the new reputation system, your points total goes down everytime you post something stupid. It's only the daily cap limit that's stopping your reputation being minus several hundred thousand.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Instead of using a foreach construct to loop over all the lines use only the first line (if I understood your question correctly):
string[] lines = File.ReadAllLines(strFilename);
string[] fragments = lines[0].Split(',');
errors.Text += fragments[0];
errors.Visible = true;
|
|
|
|
|
Yes man you did understand my question,
this works exactly the way I want it to.
Thanks alot man
|
|
|
|
|
I am using VisualStudio 2005 version. My current project is Voice Enabled system with mail client. Voice enabled system is ready it recognize my voice and perform the instruction but the main problem lies in mail client.
When ever i run the program i get this error
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
On this line the error is being displayed
((System.ComponentModel.ISupportInitialize)(this.VoiceCmd)).EndInit();
|
|
|
|
|
did u use ocx componant in your application. Try not adding COM references to the dlls but add a COM reference to the ocx file
if you still have problems try to register the ocx with regsvr32
|
|
|
|
|
Hi,
I am creating a Process in C# and want to print my "strName" value to command prompt.
This code is not printing any value , please let me know the right code.
I know this code is wrong,,but if we pass Arguents then?
string strName = "Alex";
Process pr = new Process();
pr.StartInfo.FileName = "cmd.exe";
pr.Start();
Thanks
modified on Friday, April 9, 2010 10:14 AM
|
|
|
|
|
Have you tried going into the project properties and building it as a Console Application? Then just do:
Console.WriteLine(strName);
|
|
|
|
|
I am trying to do with process.
|
|
|
|
|