Solved

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

Posted on 2004-09-27
6
752 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

19 Experts available now in Live!

Get 1:1 Help Now