Advertisement

06.17.2004 at 01:08PM PDT, ID: 21029490
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

Server.MapPath parameter length restrictions with FileScriptingObject methods?

Asked by ALoPresto in Active Server Pages (ASP)

Tags: , ,

I'm using ASP 3.0 on IIS 5.x, Win2K server.

I obtain a relative file path from a SQL database and need to establish whether or not the file exists, where it needs to be moved to, and whether it was successfully moved. All of this hinges on the Server.MapPath method, and right now I'm doing something wrong. Here is the code for the function that moves the file. I know for a fact that the file name is translating correctly (examples included):

<%
Function MoveFile(id, oldSL, newSL)
            Dim objFSO
            Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
            Dim mylocation, newLocation, myLongType
            
            mylocation = filesrc
            
            DebugW "mylocation", mylocation
            
            Select Case myFileType
                  Case "TC"
                        myLongType = "Contracts"
                  Case "TL"
                        myLongType = "Letters"
                  Case "TP"
                        myLongType = "Proposals"
                  Case "TR"
                        myLongType = "Reports"
            End Select
            
            DebugW "myFileType", myFileType
            DebugW "myLongType", myLongType
            
            myLocation = myLocation & "/" & myLongType & "/SecurityLevel" & oldSL & "/"
            newLocation = filesrc & "/" & myLongType & "/SecurityLevel" & newSL & "/"
            
            DebugW "myLocation", myLocation
            DebugW "newLocation", newLocation
            
            dim objCommand, objRS
            Set objCommand = Server.CreateObject("ADODB.Command")
            objCommand.ActiveConnection = strConnect
            objCommand.CommandText = "SELECT * FROM Documents WHERE Documents.ID = " &  id
            objCommand.CommandType = adCmdText
            Set objRS = objCommand.Execute
            Set objCommand = Nothing
            
            dim src, dest
            src = mylocation & objRS("FilePtr")
            dest = newlocation & objRS("FilePtr")
            DebugW "src", src
            DebugW "dest", dest
            Go '(Function which flushes response object buffer)
            If src = dest Then
                  MoveFile = True
            Else
                  Server.MapPath(src)
                  Server.MapPath(dest)
                  DebugW "Full src", src
                  DebugW "Full dest", dest
                  Go
                  DebugW "objFSO.FileExists(" & src & ")", objFSO.FileExists(src)
                  If objFSO.FileExists(src) Then
                        DebugW "objFSO.FileExists(" & dest & ")", objFSO.FileExists(dest)
                        If objFSO.FileExists(dest) Then
                              objFSO.DeleteFile dest, true
                        End If
                        objFSO.MoveFile src, dest
                        MoveFile = True
                  End If
            End If
            MoveFile = False
            DebugW "MoveFile", MoveFile
      End Function
%>

I'll walk through the execution.

The function gets parameters of ID, old Security Level and new Security Level. The SL's are integers which denote into which directory the file is placed.

filesrc is a globally declared variable which contains "admin/uploadfiles/".

The function then constructs the directory path - i.e. "admin/uploadfiles/Reports/SecurityLevel1/"

The file name is in the format "TX-######_#.*", where the first two characters denote the file type, the next 6 digits are the identification number (the concatenation of a two digit year and four digit IDinYr variable), and the final digit is a revision number ('version' in the database), i.e. "TR-040001_0.doc".

FilePtr is a record in the database which holds the file name, and is appended to the src and dest file paths.

I then attempt to map these paths to the server, evaluate existence, and move them.

The error I receive is that src and dest exceed the length of the parameter for the Server.MapPath method. I've seen varying documentation on the use of the parameter. Does it return a new path or does it modify the parameter? I've tried both implementations with the same error resulting.

The page that is executing this code is located in "C:\Inetpub\wwwroot\InsideTrusant\admin\"
The file repositories are in "C:\Inetpub\wwwroot\InsideTrusant\admin\uploadfiles\%Type%\%SecurityLevel%\"

I am considering simply constructing the local physical path by hand, but if anyone knows why this is not working, I appreciate it.
-------------------------
Server.MapPath() error 'ASP 0214 : 80004005'
Invalid Path parameter
/InsideTrusant/admin/edit_submit.asp, line 69
The Path parameter excedes the maximum length allowed.
-------------------------

Any function such as DebugW or ErrorW is a debugging function that prints the value of the variable(s) passed to it. Go() flushes the response object buffer (Response.Flush()).
Start Free Trial
[+][-]06.18.2004 at 12:02AM PDT, ID: 11341949

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.18.2004 at 06:05AM PDT, ID: 11343854

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.21.2004 at 10:33AM PDT, ID: 11362094

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.21.2004 at 10:35AM PDT, ID: 11362120

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.21.2004 at 11:06AM PDT, ID: 11362386

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.21.2004 at 01:26PM PDT, ID: 11363507

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.21.2004 at 02:33PM PDT, ID: 11364100

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.23.2004 at 09:51AM PDT, ID: 11381135

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: path, length, parameter
Sign Up Now!
Solution Provided By: WesLennon
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32