Live2D

C# 常用小点

1】创建文件夹

//相对路径
string FilePath = Server.MapPath("./") + "ImageFile/Images/" + DateTime.Now.Year.ToString() + "Year/" + DateTime.Now.Month.ToString() + "Month/";

DirectoryInfo di = new DirectoryInfo(FilePath);
if (!di.Exists)//如果没有就创建
{di.Create();} 

//绝对路径
                string receivePath = @"C:/ImageFile/Images/" + DateTime.Now.Year.ToString() + "Year/" + DateTime.Now.Month.ToString() + "Month/";

                DirectoryInfo di = new DirectoryInfo(receivePath);
                if (!di.Exists)
                {
                    di.Create();
                }
View Code

 

2】分割字符串

 var getStr = Str.Split(new string[] { "$tempId$" }, StringSplitOptions.None);
View Code

 

3】去除字符串中,指定字符的最后一个

string Name ="asdsa,asdsa,21321,"
 Name = Name .TrimEnd(',');

//输出之后
asdsa,asdsa,21321

 

posted @ 2018-11-02 17:04  楚景然  阅读(292)  评论(1编辑  收藏  举报