如何增加文件夹编号以避免重复 [英] How to increment folder number to avoid duplication

查看:287
本文介绍了如何增加文件夹编号以避免重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果目标号码已被使用,如何增加文件夹编号。

示例I将文件夹编号为IMG0001,但导出到目录时此文件夹已存在。基本上代码应该将文件夹编号增加到下一个可用的编号,如IMG0002,如果这已经被使用,程序将再次递增1,直到代码找到可用的编号来命名文件夹。

这样就可以避免使用重复的文件夹编号。





非常感谢您对我的问题的任何输入。

解决方案

您可以创建文件夹

通过此代码

 System.IO.Directory。 CreateDirectory(Server.MapPath( 〜/ IMG000 + i +  )); 



您可以根据您的逻辑增加i


How to increment the folder number if the target number is already in used.
Example I number a folder to IMG0001 but when exported to a directory this folder already exist. Basically the code should increment the folder number to the next available number, like IMG0002 and if this was already in use too the program will increment by one again until the code find a available number to name the folder.
In this way a duplicate folder numbering be avoided.


Thank you very much for any input for my question.

解决方案

You can create folder
By this Code

System.IO.Directory.CreateDirectory(Server.MapPath("~/IMG000" + i + ""));


You can increment i as per Your Logic


这篇关于如何增加文件夹编号以避免重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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