.NET Framework Developer Center > .NET Development Forums > .NET Base Class Library > how to use server.mappath(test.bat) in vb.net
Ask a questionAsk a question
 

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

  • Saturday, November 07, 2009 12:46 PMkokila1986 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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.

Answers

  • Saturday, November 07, 2009 2:00 PMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You can use

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

    fi=New System.IO.FileInfo(Application.StartupPath & "\" & path)
  • Saturday, November 07, 2009 4:08 PMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    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.

All Replies

  • Saturday, November 07, 2009 12:50 PMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    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)
    
  • Saturday, November 07, 2009 1:57 PMkokila1986 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    no i hve created a form in vb.net and for that i m using this code.tell me something vb.net
  • Saturday, November 07, 2009 2:00 PMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You can use

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

    fi=New System.IO.FileInfo(Application.StartupPath & "\" & path)
  • Saturday, November 07, 2009 4:06 PMkokila1986 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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?

  • Saturday, November 07, 2009 4:08 PMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    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.