|
try use , FileInfo Property for a process.
and for Exe file , just give the file name only, no need to give .exe.
Thanks
Best Regards
-----------------
Abhijit Jana
"Success is Journey it's not a destination"
|
|
|
|
|
|
Try
System.Diagnostics.Process.Start(Application.StartupPath + @"\Example.exe");
-= Reelix =-
|
|
|
|
|
Hi
I have a test certificate on my system and i would like to place this on the clients store using c# code... Can we achieve this using X509Certificate class??
|
|
|
|
|
guys please help me solve this maze program
Problem
Create a simple Maze game. You must submit multiple iterations where each iteration is in its own directory and has associated structure charts, pseudo code, and flowcharts as required.
This game is played as follows:
1. The maze contains a number of Rooms.
2. A room has a title, a description, and a number of doors which lead to other rooms.
3. Each door leads in a direction (North, South, East or West). Tthere can be multiple exits in one direction.
4. One room is the goal or target, the game ends when the player reaches this room.
5. A player starts in the starting room, the first room declared in the maze, e.g. room 1, although this could be a parameter in the data file.
6. The player is shown the title and room description of the room he is in, as well as a list of exits, from which he can choose one to take.
7. When the player goes in a direction (through a door) he is in the next room, and step 6 above is repeated.
8. The rooms for the maze are read from a text file. The following map is for the accompanying text file.
9. The format of the text file is as follows:
a. The number of rooms (int)
b. The goal room number (int)
c. For each room
i. Room title (string)
ii. Room description (string)
d. Number of exits from rooms (int)
e. For each exit
i. From room (int), to room (int), direction (char, separated by spaces on a single line)
|
|
|
|
|
|
while (!endOfMaze)
{
DoMazeSolvingLogic();
}
-= Reelix =-
|
|
|
|
|
Ah, I remember writing something like that in Pascal on a PDP-11 back in college.
I used a breadth-first algorithm.
I also chose to write a progress log to the hard drive... filled the drive and crashed the system... Good times.
I see no purpose for "3. Each door leads in a direction (North, South, East or West)."
Good luck and have fun! I did!
|
|
|
|
|
Hi Guys. In my app that I am working on I am importing a csv file into a FileHelpers engine. I take the one field from the res and use it to look up a description for it in another function, validate pcode.
I then write the output of the res + prov to a textbox. I then write the textbox data to a .txt file using StreamWriter.
I need to keep count of the totals of each prov I find. There are a total of 9 provinces and I need to list a total of each province. Can sombody advise me on the easiest way of doiing this? Below my code.
This is where I do the validation to find the appropriate province.
My apologies for the lengthy post
private string SearchPcode(string inputStr)
{
string retval = "";
int pcode = 0;
if (!int.TryParse(inputStr, out pcode))
{
retval = "Invalid Integer!";
}
else if ((pcode >= 4731) && (pcode <= 6499))
{
retval = "Eastern Cape";
}
else if ((pcode >= 9300) && (pcode <= 9999))
{
retval = "Free State";
}
else if ((pcode >= 0001) && (pcode <= 0299)
|| (pcode >= 1400) && (pcode <= 2199))
{
retval = "Gauteng";
}
else if ((pcode >=2900) && (pcode <= 4730))
{
retval = "Kwazulu Natal";
}
else if ((pcode >= 0500) && (pcode <= 0999))
{
retval = "Limpopo";
}
else if ((pcode >= 1000) && (pcode <= 1399)
|| (pcode >= 2200) && (pcode <= 2499))
{
retval = "Mpumalanga";
}
else if ((pcode >= 0300) && (pcode <= 0499)
|| (pcode >= 2500) && (pcode <= 2899))
{
retval = "North West Province";
}
else if ((pcode >= 8100) && (pcode <= 8999))
{
retval = "Northern Cape";
}
else if ((pcode >= 6500) && (pcode <= 8099))
{
retval = "Western Cape";
}
else
{
retval = "Invalid PostCode";
}
return retval;
}
This is the import for the csv file where I instantiate the search for the province.
private void btnOpenFile_Click(object sender, EventArgs e)
{
txtboxDisplay.Text = "";
txtboxPcode.Text = "";
if (openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
else
{
txtboxSelectFile.Text = openFileDialog1.FileName;
}
string filePath;
filePath = txtboxSelectFile.Text;
FileHelperEngine<CsvImp> engine = new FileHelperEngine<CsvImp>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
CsvImp[] res = engine.ReadFile(filePath);
StreamWriter sw = new StreamWriter(@"C:\SOLZ_PROV_" +
DateTime.Now.ToString("ddMMyyhhmmss") + ".txt");
if (engine.ErrorManager.ErrorCount > 0)
engine.ErrorManager.SaveErrors("Errors.txt");
foreach (CsvImp imp in res)
{
string prov = SearchPcode(imp.CallComments);
txtboxDisplay.Text += imp.CompanyCode + "\t"
+ imp.CallType + "\t"
+ imp.CallComments.ToString()
+ "\t" + prov + Environment.NewLine;
}
sw.WriteLine(txtboxDisplay.Text);
sw.Close();
}
Please advise the easiest way of keeping track and writing the totals for each province.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
If you're tracking several provinces, use a dictionary that maps an enum ( because that's more reliable than a string ) to an int, and just keep adding to the number stored for each value.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks mate. I'll go and read up on this if I can find a good article. Have not used it before. Or do you know of any article that can explain this? I haven't googled for one yet.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Dictionary<string, int> d = new Dictionary<string, int>();
void AddItem(string key)
{
if (!d.ContainsKey(key))
{
d[key] = 1;
}
else
{
++d[key];
}
}
Then you end up with a collection of keys, each is the name of an object you were counting ( I said use an enum, but I am simplifying this example ). So you iterate over the keys, and for each key, d[key] will return the number of items records for that key.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks mate. I will give this a shot and see what I come up with. I have found a few articles on the subject as well so will readup on them. Just don't have that much time left to deliver a working demo. And the Milestones changing everytime doesn't help me much either.
Thanks again.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
No worries - always glad to help. Dictionaries are an awesome container to get your head around, they have all sorts of uses. Hope it helped.
I know what you mean about shifting goals tho, we all get that.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
void AddItem(string key)
{
if (!objDict.ContainsKey(key))
{
objDict[key] = 1;
}
else
{
++objDict[key];
}
foreach (KeyValuePair<string, int> kvp in objDict)
{
txtboxTot.Text = ("Povince : " + kvp.Key + "\t" + kvp.Value);
}
}
You have two issues
1 - you're setting the textbox value inside the method that is adding them, so it's going to happen every time you add a value
2 - you set the textbox to be the last key/value pair you iterate over, because you do txtboxTot.Text = instead of txtboxTot.Text +=
Factor this code out to run when the loop that adds the values has ended, and have it add the values, instead of just showing the last one looped over. Also, use Environment.NewLine to put newlines in your textbox, if you want them ( make sure you set the textbox to be multiline )
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
THanks again mate. I got it working. One last question. Can I store multiple fields in the Dictionary? I.e. store the prov field which we are currently doing plus a few others and then itterate through them as well?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
A dictionary maps one type to another type. Either type can be a class or struct, so you can store all the values you want in a class or struct and map to instances of it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello,
I wrote a liitle program that displays a form with a button.
Once the button is pressed the program goes over the elemnts of some collection.
I would like to dispaly this elements on diffrent form, that would function as a simplified logger, on top of the existing form.
How can i do this ? must it be on a diffrent thread ? some code snippet would be great.
Thanks,
Berlus
|
|
|
|
|
your prolem is not clear from me. can you be more specific?
Thanks
Best Regards
-----------------
Abhijit Jana
"Success is Journey it's not a destination"
|
|
|
|
|
A second form would be on the same thread, just design it, and make an instance a member variable, then calling Show() would show it without stopping interaction with the main form. Show(this) would make it a proper child form. You can interact with it then via properties you expose, or use delegates to interact back to the main form
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello..
I have a ListView with CheckBoxes = TRUE. If I set FullRowSelect to TRUE, by DoubleClick (for example in Column 5) is the checkbox automatically set to TRUE or FALSE. How to avoid this ?
I want to use FullRowSelect (because of DoubleClick) but I don't want to change the state of CheckBox.
CheckBox state can only be changed, if user click on checkbox, not on "anywhere" in row.
Thx..
|
|
|
|
|
I assume you'd have to derive a class from teh control, handle the click and stop it from changing the state of the control if it's not in the right area.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I don't understand most of this "Indexer" code :
namespace UsingIndexers
{
class TestIndexers
{
private string[] MyStrings;
public TestIndexers()
{
MyStrings = new string[] { "This", "is", "an", "indexer", "test" };
}
// array like access
public string this[int index]
{
get
{
if (index < 0 || index >= MyStrings.Length)
{
throw new ArgumentOutOfRangeException();
}
return MyStrings[index];
}
set
{
if (index >= MyStrings.Length)
{
throw new ArgumentOutOfRangeException();
}
else
MyStrings[index] = value;
}
}
static void Main()
{
TestIndexers MyIndexer = new TestIndexers();
Console.WriteLine("index 1 is: {0}", MyIndexer[1]);
}
}
}
Especially I don't understand the use of indexers. Every individual element of MyStrings can be accessed through MyStrings[i]. WHy still additional code for indexing ?
And also this line of code is difficult for me :
public string this[int index]
What is the meaning of "this" ?
Any help is very much appreciated...
Many thanks in advance !!
Best regards, Steve
|
|
|
|
|
Steve Declerck wrote: Every individual element of MyStrings can be accessed through MyStrings[i]. WHy still additional code for indexing ?
But your data should be private. The indexer allows you to expose a public interface (don't confuse that with a C# interface ) for your private data. Of course, you could do away with an indexer and use a GetXXX(int index) method, but indexers are elegant. You are not limited to integers; you can also use other types for the indexer.
Steve Declerck wrote: public string this[int index]
What is the meaning of "this" ?
this is a keyword used to refer to the home object, i.e., the object on which the code is operating.
I don't mean to be condescending, but a good book will explain all of this in greater detail. I'd recommend Andrew Troelsen.
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
Hello Vikram,
Thank you very much for your fast reply ! I understand it now...
Thanks, Steve
|
|
|
|