我想向文本框里面输入一个字符串,然后用这个字符串作为新建文件的名字,这个能实现么

解决方案 »

  1.   

    可以。
    但是要符合规范:
    (1)驱动器存在
    (2)路径存在
    (3)没有同名的文件夹或者文件
    (4)没有非法字符,比如 / \ " | * ? 等等
    (5)没有保留字,比如 lpt com1
      

  2.   

    using System.IO.     
       string name = TextBox1.Text.Trim();
           string dir = Server.MapPath("File");//制定File文件夹路径
           File.Create(dir + "test.txt"); //