Results 1 to 19 of 19

Thread: Map server path

  1. #1

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Map server path

    I have my default IIS folder as 'asp' and under that I have the 'docs' folder.
    How would I specify the server path to save or find a file.

    Thanks
    PK

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Map server path

    Quote Originally Posted by Peekay View Post
    I have my default IIS folder as 'asp' and under that I have the 'docs' folder.
    How would I specify the server path to save or find a file.
    If you still use the basic-approach as outlined here:
    https://www.vbforums.com/showthread....g-of-http-RPCs

    ...then you can put a breakpoint in the cAsp-HandleRequest method -
    and then experiment in the Immediate-Window with the output of:
    ? Server.MapPath("")
    ? Server.MapPath("/")
    ? Server.MapPath("/asp")
    ? Server.MapPath("/asp/docs")

    HTH

    Olaf

  3. #3

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Thanks Olaf,

    My IIS is still set up as you advised.

    When I run the Group project, it does not use the server code group, because the .dll is running on my development machine, and it is using that.
    In that program I developed last year (thankfully with your help), I see I that have used "Docs/..." as the relfoldername.
    I am using the following code with relFoldername="Docs/... etc.", but with anything to do with "docs/.." or whatever, it gives me false:

    Code:
    Function FolderExists(RelFolderName As String) As Boolean
      Dim RsResult As ADODB.Recordset
      Set RsResult = RPC.DoRPC("FolderExists", RelFolderName)
      If NoErrorIn(RsResult) Then FolderExists = RsResult(0)
    End Function
    I have also tried the above in immediate mode with prejudged paths, but it gives me false, whilst I know the folder does exist there.

    Here is how I test in my code whether the file I wish to upload, does not already exists:

    Code:
    'is there such a folder
    If modFileOpsRPC.FolderExists("Docs/OfficeManage/" & cboDocFolders.Text) = False Then
        'create folder
        If modFileOps.CreateDirectory("Docs/OfficeManager/" & cboDocFolders.Text) = False Then WarnUser Failure, " Folder " & "Docs/OfficeManager/" & cboDocFolders.Text & " could not be created": Exit Sub
    End If
    'is there not already such a filename
    Code:
    If modFileOps.FileExists("Docs/OfficeManager/" & cboDocFolders.Text & "/" & txtDocName.Text) = True Then WarnUser Failure, " File " & "Docs/OfficeManager/" & cboDocFolders.Text & "/" & txtDocName.Text & " already exists. Try another name": Exit Sub
    End If
    I know the solution is staring me in the face, but my eyes are closed.

    Thanks
    PK
    Last edited by Peekay; Aug 23rd, 2021 at 02:15 AM.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Map server path

    In the second of your 3 Code-Blocks in Line 2: Is that a Typo?

    If modFileOpsRPC.FolderExists("Docs/OfficeManage/" & cboDocFolders.Text) = False Then

    Is there an "r" missing in OfficeManage?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Thanks guys,

    All is well now. I should have had IF NOT in stead of IF.

    PK

  6. #6

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    I get an error when I want to create a folder like in:

    Code:
    'does the folder exist?
    If Not modFileOps.FolderExists(FolderName) Then 'frmAll.WarnUser Failure, " The folder path '" & FolderName & "' does not exist. Contact your administrator":  Exit Sub
        Reply = MsgBox("The folder '" & FolderName & "' does not exist" & vbCrLf & "Do you wish to create it?", vbExclamation + vbYes + vbNo)
        If Reply = vbNo Then Exit Sub
        If Not modFileOps.CreateDirectory(FolderName) Then frmAll.WarnUser Failure, " Folder " & FolderName & " could not be created.":  Exit Sub
    End If
    The foldername='docs/myfolder' does exist.

    What is the path FolderName has to start with if my full path is : 'C:/inetpub/wwwroot/asp/docs/myfolder', for finding out if it exists and for creating it if it does not exist?

    Thanks
    PK

  7. #7
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Map server path

    Huh?
    Create it if it doesn't exist, and if it exists all is well?
    https://docs.microsoft.com/en-us/win...tedirectoryexw
    This function creates a file system folder whose fully qualified path is given by pszPath. If one or more of the intermediate folders do not exist, they are created as well.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  8. #8

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Is there a reason why my tested routine above will return false whilst there is such a folder in the path. Does the localhost not prevent me from seeing it?

    PK

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Map server path

    Did you ever ran your serverside project in Debug-Mode -
    and then followed the instructions I already gave in post #2?

    Olaf

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: Map server path

    Quote Originally Posted by Peekay View Post
    Is there a reason why my tested routine above will return false whilst there is such a folder in the path. Does the localhost not prevent me from seeing it?

    PK
    You did try the fully qualified path instead of your relative path?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  11. #11

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Olaf,
    The problem is that the .dll is registered on my development machine, thus, when I run the group, it takes the compiled .dll which I cannot put a stop on. Is there a way to stop this without deregistering the .dll?

    Zvoni,
    I have tested the full path and parts of it.

    What puzzles me is that this routine worked very well until now, and the path it worked with was "Docs/IBMS/OfficeManager", which it now cannot pick up.

    PK

  12. #12
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Map server path

    Quote Originally Posted by Peekay View Post
    The problem is that the .dll is registered on my development machine, thus, when I run the group, it takes the compiled .dll which I cannot put a stop on. Is there a way to stop this without deregistering the .dll?
    If deregistering helps - then go for it...
    (I have two helper-icons on my desktop, where I can just drop an Ax-Dll for register and un-register).

    It might also help (when you plan such a switch from "production" into "debugging-mode"),
    that you stop and restart the IIS on your dev-machine (there's links for that in the IIS-manager at the top-right).

    Olaf

  13. #13

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Olaf,

    Thanks. I have done that.
    A part of My handler routine all of a sudden gives and error:

    Code:
     Public Function GetRs(Cnn As adodb.Connection, ByVal SQL As String, ParamArray P()) As adodb.Recordset
      
      Set GetRs = New adodb.Recordset
      
      Dim cmd As New adodb.Command, i As Long
      Set cmd.ActiveConnection = Cnn
          cmd.CommandText = SQL
      For i = 0 To UBound(P)
        Select Case VarType(P(i))
          Case vbString
            cmd.Parameters.Append cmd.CreateParameter(, adVarChar, , 4096, P(i))
          Case Else
            cmd.Parameters.Append cmd.CreateParameter(, VarType(P(i)), , , P(i))
        End Select
      Next
    
      GetRs.CursorLocation = adUseClient
      ADOerror = ""
      GetRs.Open cmd, , adOpenStatic, adLockBatchOptimistic
        If GetRs Is Nothing Then ADOerror = Error
      'If Error <> "" Then Debug.Print Error
      GetRs.Properties("Update Criteria") = adCriteriaKey 'allow only PKs, to locate Rows for Updates in the Where-Clause
      If TrueDisconnectedMode Then Set GetRs.ActiveConnection = Nothing
      Set cmd.ActiveConnection = Nothing
    
    'Debug.Print "Value of recordset after being opened in GetRs on server side: ", GetRs.Fields(0).Name
    
    End Function
    It says 'Can't find project or library'

    Can you please help.

    Thanks
    PK

  14. #14
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Map server path

    Quote Originally Posted by Peekay View Post
    It says 'Can't find project or library'
    Did you start the Debugging from a Group-File (*.vbg)?

    If you already run a *.vbg,
    did you check all external lib-references (like e.g. to ADO)?

    Olaf

  15. #15

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Thanks Olaf,

    Reply changed.
    The mistake was not starting from a wrong group file.
    It is in the recordset routine and I have Microsoft Active Data Objects 2.5 library marked with no missing references.

    PK
    Last edited by Peekay; Oct 22nd, 2021 at 06:27 AM.

  16. #16
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Map server path

    Quote Originally Posted by Peekay View Post
    Thanks Olaf, my mistake was not starting from a group file.
    Great, so now you can experiment by setting a breakpoint in cASP.HandleRequest -
    and check the output of the following command:

    ? Server.MapPath("/")

    in the Immediate-(Debug-)Window.

    In short, the above command will give you the Root-Path of your IIS-installation
    (usually "c:\inetpub\wwwroot" -but that depends on the settings in the IIS).

    So you could enhance your Server-Dll-Proect about a Public-Variable (in a *.bas) like:

    Public SrvRoot As String

    ...and then fill it when entering cASP.HandleRequest like:

    SrvRoot = Server.MapPath("/")
    'then making sure, you append a BackSlash to it, so that it is ready for String-Concatenations

    All incoming *relative* Paths (in your Request-Handler Subroutines) -
    should then use SrvRoot as the first part of a concatenation, (to build a proper absolute path).

    MyAbsPath = SrvRoot & Replace(RelPathFromIncomingMethodParam, "/", "\")

    HTH

    Olaf
    Last edited by Schmidt; Oct 23rd, 2021 at 02:12 PM.

  17. #17

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    Olaf,

    Your #16 refers.
    That is a very good tip thanks.
    Still battling with the Error error.

    PK

  18. #18

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    What puzzles me is that the path I have in my program was correct previously, but now it does not work.
    In fact, all my other programs using this routine still work perfectly.
    It must be some other stupid mistake I am overlooking

    PK

  19. #19

    Thread Starter
    Fanatic Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    784

    Re: Map server path

    I have solved it.
    It seems I have to use the modFileOpsRPC routines instead of my modFileOps routines
    I do not know why.

    PK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width