Click here to Skip to main content
15,910,980 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

create new folder which is not exists in parent folder, until condition satisfied to create new folder.we can create folder by increment number. need code in asp.net c#

example

if folder exists = test
else if folder exists = test1
.
.
.
until condition satisfied.
Posted
Comments
CHill60 4-Apr-15 8:01am    
What is your question?
Mohan Subramanian 4-Apr-15 8:04am    
pls read it clearly otherwise leave it.
OriginalGriff 4-Apr-15 8:17am    
Don't be rude or arrogant: Remember that we can't see your screen, access your HDD, or read your mind.

What is "a clear question" to with your knowledge of the context of your task is not necessarily clear to those of us who only get to read exactly what you wrote. And your question is not clear to CHill60, or to me.

So lose the attitude, and try to remember that we are volunteers helping others - not a service you pay for. Annoying those you want help from is not generally a good way to encourage them to assist you. Even if people are paid to be there and help you (which we aren't) you will generally get better service and better help by treating them the way you would like to be treated.
CHill60 4-Apr-15 8:59am    
Thank you - a far politer response to the OP that mine would have been I think.
I note that all of their questions (that I bothered to read) are of the "gimme code" variety :(
OriginalGriff 4-Apr-15 9:51am    
You're welcome!
(Abuse was the first thing that crossed my mind when I saw his comment as well...)

1 solution

Your question isn't very clear, but I think I've worked out what you mean...
Try this:
C#
bool condition = true;
string basePath = @"D:\Temp\";
string fullpath = "";
int i = 1;
while (condition)
    {
    fullpath = Path.Combine(basePath, i++.ToString("000000"));
    condition = Directory.Exists(fullpath);
    }
Directory.CreateDirectory(fullpath);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900