创建文件夹直到条件满足.... [英] create folder until condition statisfied....

查看:86
本文介绍了创建文件夹直到条件满足....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





创建父文件夹中不存在的新文件夹,直到条件满足创建新文件夹。我们可以按增量编号创建文件夹。需要asp.net中的代码c#



示例



如果文件夹存在=测试

否则,如果文件夹存在= test1







直到满足条件。

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.

推荐答案

你的问题不是很清楚,但我想我已经解决了你的意思......

试试这个:

Your question isn't very clear, but I think I've worked out what you mean...
Try this:
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);


这篇关于创建文件夹直到条件满足....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆