Solved

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

Posted on 2004-09-27
6
776 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

791 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