一个客户端程序,访问网站的页面如www.sss.com/a.aspx,这个页面有一个脚本,会打开服务器上的文本文件,进行读取判断文本内容是不是1,如果合格,文本改为0,如是0,则程序不执行。
请问,这个程序和脚本怎么搞呀。

解决方案 »

  1.   

    这样直接访问不行吗?
    Dim fileContents As String
    fileContents = My.Computer.FileSystem.ReadAllText(Server.MapPath("") & "\1.txt")
    if fileContents="1" then My.Computer.FileSystem.WriteAllText(Server.MapPath("") & "/1.txt", "0", False)
      

  2.   

    没有十分明白你的意思,看看是否符合你的要求。
    try{
        String path = "c:\\file.txt";
        int num = ReadNum(path);
        if( num<0 ){
    //获得文本异常
    // End...
        }
        if( num>0 ) {
            CreateFile(0.ToString(), path);
        } else if(num==0 ) {
            Response.End();
        }
    }catch(Exception ex){
        Response.Write(ex.ToString());
    }
    public static int ReadNum(String path){
    using(System.IO.StreamReader sr = new System.IO.StreamReader(path)){
        int num = -1;
        try{
    num = int.Parse(sr.ReadToEnd().Trim());
    }catch(Exception ex){
    throw new Exception(ex.ToString());
    }finally{
    sr.Close();
    }
        }
        return num;
        }
    }
    public static void CreateFile( String str, String path)
    {
        System.IO.StreamWriter objSW = null;
        try{
    objSW = new System.IO.StreamWriter( path);
    objSW.Write(str);
    objSW.Flush();
    objSW.Close();
        }catch( Exception ex ){
    throw new Exception(ex.ToString());
        }
    finally
        {

        if( objSW != null ){
            objSW.Close();
    objSW = null;
        }
    }
      

  3.   

    这是我写的读的
    function ReadFiles()
    {
    var fso, f1, ts, s;
    var ForReading = 1;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    &nbsp;&nbsp;&nbsp;// 读取文件的内容。
    &nbsp;&nbsp;&nbsp;Response.Write("Reading file &lt;br&gt;");
    &nbsp;&nbsp;&nbsp;ts = fso.OpenTextFile("c:\\testfile.txt", ForReading);
    &nbsp;&nbsp;&nbsp;s = ts.ReadLine();
    &nbsp;&nbsp;&nbsp;Response.Write("File contents = '" + s + "'");
    &nbsp;&nbsp;&nbsp;ts.Close();
    }