none
How do I access my own directory RRS feed

  • Question

  • I am asking this question in this forum in the hope that someone will provide a simple answer to what I thought was a trivial problem.  I have three different projects that I have working very well in my Visual Studio Environment.  My solutions all have a common directory for obtaining application specific data and creating reports for various users.  This has allowed me to develop and test in my environment without interruption.  In my code, using VB, I merely change directory to "/SDATA" proceed using normal file IO for whatever.  My problem occurs when I deploy these applications.  My server rejects the use of C:\Sdata for obvious reasons.  Here is where I am stuck!

    I need a method of setting my directory to the server's root.  I was given an answer on another forum that said I need to employ environment.special folder.  I am unsure if this is what I am seeking and in trying to understand it in its documentation I drew a complete blank.  Can someone out there confirm or hopefully deny, that the answer lies in what I have said?  If you deny, can you provide me with an alternative for accomplishing what I need?  It seems to me that ultimately I need a reference or a logical assignment to the server's root directory.


    eps123


    • Edited by eps123 Wednesday, June 8, 2016 4:26 PM
    Wednesday, June 8, 2016 4:23 PM

Answers

  • I finally solved it with the little routine pasted below
    Imports System.IO
    'the objective of this little routine is to test the ability to deploy the application and execute successfully on the website
    'The routine executes successfully in the vs2013 local server environment but after deployment, fails on the server.
    'Initially, the directory was positioned in the c:\ root which was ideal since multiple projects must access the directory, SDATA.
    'The failure on the site was that C:\ is an invalid path, which is understandable although it was employed only as "\".
    'This version has placed the directory in the root folder via the rootpath statement.A modest success is demonstrated when the directory content
    'of "PERMDB.OUT" and the path to the directory are displayed.
    Public Class _Default
        Inherits Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim s As String, i As Integer, getprop As String, apath, a1, a2 As String
            Dim rootpath = Server.MapPath("~") 'this is the applicaiton's root path
            ChDir(rootpath & "\SDATA")
            s = CurDir()
            TextBox2.Text = s
            s = Dir("permdb.*")
            rootbox.Text = s
        End Sub
    
       End Class
    



    eps123

    • Marked as answer by eps123 Friday, July 22, 2016 1:39 PM
    Friday, July 22, 2016 1:37 PM

All replies

  • IDK if it willhelp, but give it a try

    BP-LP 2005/2016 @ll rights reserved

    Wednesday, July 6, 2016 10:55 PM
  • I finally solved it with the little routine pasted below
    Imports System.IO
    'the objective of this little routine is to test the ability to deploy the application and execute successfully on the website
    'The routine executes successfully in the vs2013 local server environment but after deployment, fails on the server.
    'Initially, the directory was positioned in the c:\ root which was ideal since multiple projects must access the directory, SDATA.
    'The failure on the site was that C:\ is an invalid path, which is understandable although it was employed only as "\".
    'This version has placed the directory in the root folder via the rootpath statement.A modest success is demonstrated when the directory content
    'of "PERMDB.OUT" and the path to the directory are displayed.
    Public Class _Default
        Inherits Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim s As String, i As Integer, getprop As String, apath, a1, a2 As String
            Dim rootpath = Server.MapPath("~") 'this is the applicaiton's root path
            ChDir(rootpath & "\SDATA")
            s = CurDir()
            TextBox2.Text = s
            s = Dir("permdb.*")
            rootbox.Text = s
        End Sub
    
       End Class
    



    eps123

    • Marked as answer by eps123 Friday, July 22, 2016 1:39 PM
    Friday, July 22, 2016 1:37 PM
  • I think you should close the comments with another ' so the code will not be all green.

    Greetings

    Friday, July 22, 2016 2:00 PM
  • Good for you

    BP-LP 2005/2016 @ll rights reserved

    Friday, July 22, 2016 7:39 PM