Solved

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

Posted on 2004-09-27
6
764 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 500 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
currencylayer API intergrate to ASP 25 66
toggle checkboxes when a checkbox is checked 16 52
Forcing form refresh - classic ASP 7 59
Need help editing script 3 67
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now