Question: In web application, I have an arraylist, 

```
   ArrayList lists = new ArrayList();
        lists.Add("S");
        lists.Add("A");
        lists.Add("S");
        lists.Add("I");
        lists.Add("D");
        lists.Add("H");

```

now i am trying to remove the arraylist items with no of count.
 that means if i have count =8 then loop will run for 8 times and remove the arraylist item like :

```
   1 2  3  4 5 6 7 8 
   S A  S  I D H S **A**

   A is removing from arraylist

  after that  arraylist is  S S I D H only again

   1 2 3 4 5 6 7 8 
   S  S I D H S S **I**

   I is removing from arraylist

   like this upto single item in arraylist .

```

i used for condition but no use.
my code is 

```
     ArrayList lists = new ArrayList();
        lists.Add("S");
        lists.Add("A");
        lists.Add("S");
        lists.Add("I");
        lists.Add("D");
        lists.Add("H");

        int lent =8;

        for (int k = 1; k <= lent; k++)
        {
            if (k == lent)
            {
                if (lists.Count == 1)
                {
                    break;
                }
                else
                {

                    lists.RemoveAt(k-1);                        
                    k = 0;
                }
            }
        }

```

Answer: 
```
#include <windows.h>
#include <Shlwapi.h>
// remember to link against shlwapi.lib
// in VC++ this can be done with
#pragma comment(lib, "Shlwapi.lib")

// ...

TCHAR buffer[MAX_PATH]={0};
TCHAR * out;
DWORD bufSize=sizeof(buffer)/sizeof(*buffer);
// Get the fully-qualified path of the executable
if(GetModuleFileName(NULL, buffer, bufSize)==bufSize)
{
    // the buffer is too small, handle the error somehow
}
// now buffer = "c:\whatever\yourexecutable.exe"

// Go to the beginning of the file name
out = PathFindFileName(buffer);
// now out = "yourexecutable.exe"

// Set the dot before the extension to 0 (terminate the string there)
*(PathFindExtension(out)) = 0;
// now out = "yourexecutable"

```

Now in out you have a pointer to the "base name" of your executable; keep in mind that it points inside `buffer`, so when `buffer` goes out of scope `out` is not valid anymore.
[`GetModuleFileName(NULL, .....)`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx) 

> 
> But I can't find any good example of usage of that function
> 
> 
> 

[You haven't tried hard enough.](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683500%28v=vs.85%29.aspx)
"Examples" section in ["GetModuleFileName"](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx) article on msdn