Microsoft Developer Network > Página Inicial dos Fóruns > .NET Base Class Library > how to use server.mappath(test.bat) in vb.net
Fazer uma PerguntaFazer uma Pergunta
 

Respondidohow to use server.mappath(test.bat) in vb.net

  • sábado, 7 de novembro de 2009 12:46kokila1986 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Dim path As String
            path = "test.bat"
            Dim sw As System.IO.StreamWriter
            Dim fi As System.IO.FileInfo 
            fi = New System.IO.FileInfo(Server.MapPath(path))
            sw = fi.CreateText()
            'The List Of Operations you want to execute.
            sw.WriteLine("cd c:\\")
            sw.WriteLine("md c:\\dummy")
            sw.WriteLine("cd dummy")
            sw.WriteLine("C:\\winJavaCoverage\\bin\\javacoverage -F c:\\test.java")
            sw.WriteLine("javac Pack\\Test.java")
            sw.WriteLine("java Pack\\Test")
            sw.Close()

    this is the code i hve used behind my form in vb.net.it is not wrking as it is showing error as server in server.mappath is not declared.i dnt know what to do.i hve tried my best.can u pls tell me so that i can run and gets the benefit.

Respostas

  • sábado, 7 de novembro de 2009 14:00Tamer OzMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    You can use

    Application.StartupPath gives you the path executable of your application.

    fi=New System.IO.FileInfo(Application.StartupPath & "\" & path)
  • sábado, 7 de novembro de 2009 16:08Tamer OzMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    Response.Write writes a string to the response stream with another saying basicly in page in asp.net

    In windows forms you can use MessageBox.Show to show messages.

Todas as Respostas

  • sábado, 7 de novembro de 2009 12:50Tamer OzMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Contém Código
    Server.Mappath could only be used in asp.net applications.

    Is your application Asp.net or Windows Application.

    If it is asp.net application try.

    System.Web.HttpContext.Current.Server.MapPath(Path)
    
  • sábado, 7 de novembro de 2009 13:57kokila1986 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    no i hve created a form in vb.net and for that i m using this code.tell me something vb.net
  • sábado, 7 de novembro de 2009 14:00Tamer OzMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    You can use

    Application.StartupPath gives you the path executable of your application.

    fi=New System.IO.FileInfo(Application.StartupPath & "\" & path)
  • sábado, 7 de novembro de 2009 16:06kokila1986 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    thank u so much for ur response.this helped me.

    can u tell me 1 mre thing.

    this.Response.Write(String.Format(fmtOutput, results.Replace(System.Environment.NewLine, "")))

    the above statement gives error as response is not declared.i have done few things like i hve used me instead of this or form1.

    but nothing works.can u tell me what shd i do?

  • sábado, 7 de novembro de 2009 16:08Tamer OzMVPMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    Response.Write writes a string to the response stream with another saying basicly in page in asp.net

    In windows forms you can use MessageBox.Show to show messages.