Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I use FileExists  in ASP  to check files on different server ?

Posted on 2004-09-27
6
Medium Priority
?
803 Views
Last Modified: 2007-12-19
I need to create a folder on a different server with asp, I tried server.mappath but it does not like the path I give it

How can I accomplich this...

<%
Dim FSO,F

Set FSO=Server.CreateObject("Scripting.FileSystemObject")

If FSO.FolderExists(Server.Mappath("//ab/sharedFolder/Customers/NameofFolder")) then
        Response.Write "Folder Exist"
Else
        Set F = Fso.CreateFolder(Server.Mappath("//ab/sharedFolder/Customers/NameofFolder))
        Response.Write "Folder was created"
End If
%>
0
Comment
Question by:JonMny
6 Comments
 
LVL 4

Expert Comment

by:mistyrae
ID: 12160823
Hi,

You can map a path to a location on another server. The server.mappath function is only to turn relative paths (from within your website) into fully qualified paths.

Provided your website is running under and account that has the proper permissions to the remote server, you can check FolderExists on a UNC path, like:

If FSO.FolderExists("\\myservername\mysharename$\myfolderpath") Then
  .....


- misty
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 1500 total points
ID: 12160855
Also, it will be necessary to duplicate the IUSR account on the other server or else you will get a permissions error. Please see:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q184566

FtB
0
 

Expert Comment

by:ashaydo
ID: 12160893
Server.MapPath Returns the physical path based on the web path passed:

  strWebRootPath = Server.MapPath("/")
  strCurrentPagePath = Server.MapPath("./")

Is ab your other server in this case?
If so, you'll want the folderexists method to look like this:
  FSO.FolderExists("\\ab\sharedFolder\Customers\NameofFolder")

If you want see if your folder on the current server exists on the other server:
  FSO.FolderExists("\\otherserver\Replace(Server.MapPath("/Customers/NameOfFolder"), ":", "$"))
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Author Comment

by:JonMny
ID: 12161106
Okay , I am not able to get the permissions I need for the server to be able to do this.

Would it be possible to Create the folder using the users credentials, Or can I hav a script that runs on the user side somehow
0
 

Expert Comment

by:ashaydo
ID: 12161129
In IIS, if you turn on Windows Authentication and turn off Anonymous authentication, the user's credentials should be the ones being used.

The user would then, of course need to have the appropriate rights to the path that you are specifying in the FSO.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12161156
Please see the link that I provided above.

FtB
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Loops Section Overview
Screencast - Getting to Know the Pipeline

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question