创建唯一名称 [英] Create Unique Names

查看:162
本文介绍了创建唯一名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,如从Web应用程序上传文件,您需要创建唯一的名称。因为有可能不同的用户可以上传不同的或相同的文件具有相同的名称,它是不允许的。



所以有时我们需要使用这样一个函数来创建我们独特的名字/字符串。

什么是解决方案?$ b $因此,让我们开始:

这是其中一个解决方案:

$ b
$ b

  public static string CreateFileName()
{
return Guid.NewGuid()。ToString()。Replace( - );
}


In some cases like uploading files from web application you need to create unique names.Because it is possible that different users can upload different or same files with same name and it is not allowed .

So sometimes we need to use such a function which will create us unique names/strings.

What are solutions ?

解决方案

So lets start:

This is one of the solutions:

public static string CreateFileName()
{
    return Guid.NewGuid().ToString().Replace("-", ""); 
}

这篇关于创建唯一名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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