Recognize a folder Winforms

  • Thread starter Thread starter Carlo Goretti
  • Start date Start date
C

Carlo Goretti

Guest
Hey!

I need som help right now..
Im making a program that looks like this.

If you write a name in the second textbox and click "SkapaMapp" then it will create a folder with the Textbox as the name and a number like this:

The numbers are a counter and will be higher for every folder that exist there.
I have tryied to make so if you write "Test" again in the textbox then i want to look if the folder alredy exists and if it exists i want a messagebox to say "Hello i found "Test"". Here is my code but i dont get it right.. As i said above, it can be higher and lower numbers but it is allways a number then a "." and then the name..
Any ideas how to solve this?
Here is my code:


KundLänk = StandardSökvägTxt.Text.Substring(0, StandardSökvägTxt.Text.LastIndexOf(@"\") + 1);
string antal = "";
foreach (string d in System.IO.Directory.GetDirectories(KundLänk))
{
DirectoryInfo dir = new DirectoryInfo(d);
string dirName = dir.Name;

if (dirName != "Standard_Uppsättning")
{
Antal = dirName.Substring(dirName.IndexOf("."));
}


if (Antal == "." + KundNamnTxt)
{
//Antal = dirName.Substring(0, dirName.IndexOf("."));
// int test = Convert.ToInt32(Antal);
//DirectoryCount.Add(Convert.ToInt32(Antal));
//DirectoryCount.Sort();
KundMapp = dirName;

}
Just ask if you have any questions!
Thanks for the help!
Best regards!

Continue reading...
 
Back
Top