问题
i have this problem, I want create this filename of xml file:
NOHEL+number.xml
The number is from variable number, where i added +1 always when i send file out. NOHEL is prefix. Exapmle:
NOHEL1.xml
NOHEL2.xml
NOHEL3.xml
And i want give there...
string strFileName = @"C:\\Users\\L\\Desktop\\NOHEL+number.xml";
Have you any ideas?
回答1:
Try this:
string strFileName = @"C:\Users\L\Desktop\NOHEL" + number + ".xml";
By the way, you don't need to escape characters with \
when you have @
.
回答2:
You can use
string.Format(@"C:\Users\L\Desktop\NOHEL{0}.xml", number)
or
@"C:\Users\L\Desktop\NOHEL" + number + ".xml".
And there is no need to make double slash when you use @ symbol.
来源:https://stackoverflow.com/questions/18381556/file-name-with-prefix-and-number