Forum  General Visual ...  How do I...?  How do I get the phyiscal path of the application?
Previous Previous
 
Next Next
New Post 5/16/2012 9:34 AM
  sramirez@dynacal.com
508 posts
1st Level Poster


How do I get the phyiscal path of the application? 

I am trying to use the following function that I found on your wiki:

    Public Function GetPrivateVersion(ByVal webConfigPath As String) As Integer
        Dim ret As Integer = 0

        'Retrieve the physical path of the web.config file.
        Dim configXmlDoc As New XmlDocument()
        configXmlDoc.Load(webConfigPath)

        ' read the config settings
        Dim oList As XmlNodeList = configXmlDoc.SelectNodes("configuration/WebGui/PrivateVersion")
        For i As Integer = 0 To oList.Count - 1
            If oList(i).Name = "PrivateVersion" Then
                Dim oValue As XmlAttribute = oList(i).Attributes("Value")
                ret = CInt(oValue.Value)
            End If
        Next
        configXmlDoc = Nothing
        Return ret
    End Function

 

However, I don't know how to get to the web's physical root folder so I can pass in the web.config path and filename.

 

Thanks,

Shawn

 
New Post 5/16/2012 11:33 AM
  Jim.Halliday
84 posts
No Ranking


Re: How do I get the phyiscal path of the application? 

 Hi Shawn,

I use:    Context.Server.MapPath(Context.Request.ApplicationPath)  

Regards

Jim

 
New Post 5/16/2012 3:07 PM
  JamesC
849 posts
www.redcastle.co.uk
1st Level Poster




Re: How do I get the phyiscal path of the application? 

hi Shawn\Jim,

I use:

string rootpath = VWGContext.Current.Server.MapPath("~");

I expect there's even more ways of doing it though...

cheers james

 
New Post 5/17/2012 11:07 AM
  palli
14295 posts
1st Level Poster




Re: How do I get the phyiscal path of the application? 

 Hi Shawn,

I usually use James's method and the full physical path to web.config would be VWGContext.Current.Server.MapPath("~/web.config");

Thanks to Jim and James,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 6/5/2012 11:33 AM
  sramirez@dynacal.com
508 posts
1st Level Poster


Re: How do I get the phyiscal path of the application? 

How would I go about changing the private version from code?  I believe that the VWG app will reset after I set the private version and I am ok with that.

I am using the following code to read the private version:

        Dim configXmlDoc As New XmlDocument()
        configXmlDoc.Load(webConfigPath)

        ' read the config settings
        Dim oList As XmlNodeList = configXmlDoc.SelectNodes("configuration/WebGUI/PrivateVersion")
        For i As Integer = 0 To oList.Count - 1
            If oList(i).Name = "PrivateVersion" Then
                Dim oValue As XmlAttribute = oList(i).Attributes("Value")
                ret = CInt(oValue.Value)
            End If
        Next

 

Thanks much,

Shawn

 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  How do I get the phyiscal path of the application?
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS