我生成一个xml我的路径是:@"d"\test.xml";
如果我生成的时候
1:在项目里面直接生成路径是怎样的呢?
2:在项目里面里面的一个image的文件夹直接生成路径是怎样的呢?

解决方案 »

  1.   

    Server.MapPath("写上你的虚拟路径")
      

  2.   

    protected void Button1_Click(object sender, EventArgs e)
        {
            string path = "../image/" + TextBox1.Text + ".xml" ;
            if(File.Exists(path))
            {
                File.Delete(path);
            }
            string aa = "<?xml   version='" + "1.0" + "'   encoding='" + "gb2312" + "'?>"
              + "<Prospectus>"
              + "<Step   StepId='" + "1" + "'   sss   =   '" + "2" + "'>"
              + "<aa>aaa</aa>"
              + "<bb>"
              + "<b_1>sfsdf</b_1>"
              + "</bb>"
              + "</Step>"
              + "</Prospectus>";
            using (FileStream fs = File.Create(path, 1024))
            {
                Byte[]info=new UTF8Encoding(true).GetBytes(aa);
                fs.Write(info,0,info.Length);
            }
        }
    看看那里错了?