473,388 Members | 1,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

WebRequest to see if Directory exists

I am trying to find out is a folder exists within a share on a server. I can
successfully determine if a file exists within the share, but I can't figure
out how to determine if it's parent folder exists.

This is what I'm trying:

Dim fwrqFolder As FileWebRequest
Dim fwrFolder As FileWebResponse
Dim uriFolder As Uri

Try
Dim strPathName as String = "10.0.0.50/DemoProj/PDQ"
uriFolder = New Uri("file://" & strPathName)
fwrqFolder = CType(WebRequest.Create(uriFolder),
FileWebRequest)
fwrFolder = CType(fwrqFolder.GetResponse(),
FileWebResponse)
Catch err As WebException
MsgBox(("WebException: " + err.Message))

The error says: Access to the path "\10.0.0.50\DemoProj\PDQ" is denined.
However, if I add an existing filename to the path it works.

The share is defined as a Virtual Directory with Read, Write, and Directory
Browsing. Directory Security is set to allow Anonymous access.

Any suggestions?

Thanks...Steve

Nov 23 '05 #1
1 3966
Hi Steven,

Assuming you are using this logic from within a web service, you're going
to have issues due to the "managed" part of managed code implementation.
Under most circumstances (all if you love your server), try and avoid
giving remote callers logic that directly touches the local disk.

Another problem you will have is that the file system isn't IP addressable
like this - you'd have to put local disk manipulation functions within your
server side implementation, and then change the sandbox security so that
the special file system type called a directory can be "opened" and "read"
by the web service code. The code you have here seems on the surface to be
inadequate to do what you are trying to do.

The classes System.IO.Directory and System.IO.DIrectoryInfo seem to be
better suited to the problem space you seem to want to attack.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: WebRequest to see if Directory exists
thread-index: AcToTbDdSVhZFUvIST+h/342wtJUug==
X-WBNR-Posting-Host: 216.162.164.190
From: "=?Utf-8?B?U3RldmVuIEouIFJlZWQ=?="
<St*********@discussions.microsoft.com>
Subject: WebRequest to see if Directory exists
Date: Wed, 22 Dec 2004 09:43:05 -0800
Lines: 30
Message-ID: <B0**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8268
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I am trying to find out is a folder exists within a share on a server. I
can
successfully determine if a file exists within the share, but I can't
figure
out how to determine if it's parent folder exists.

This is what I'm trying:

Dim fwrqFolder As FileWebRequest
Dim fwrFolder As FileWebResponse
Dim uriFolder As Uri

Try
Dim strPathName as String = "10.0.0.50/DemoProj/PDQ"
uriFolder = New Uri("file://" & strPathName)
fwrqFolder = CType(WebRequest.Create(uriFolder),
FileWebRequest)
fwrFolder = CType(fwrqFolder.GetResponse(),
FileWebResponse)
Catch err As WebException
MsgBox(("WebException: " + err.Message))

The error says: Access to the path "\10.0.0.50\DemoProj\PDQ" is denined.
However, if I add an existing filename to the path it works.

The share is defined as a Virtual Directory with Read, Write, and Directory
Browsing. Directory Security is set to allow Anonymous access.

Any suggestions?

Thanks...Steve
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steven J. Reed | last post by:
I am trying to find out is a folder exists within a share on a server. I can successfully determine if a file exists within the share, but I can't figure out how to determine if it's parent folder...
0
by: CodeMotion | last post by:
I have access to an internet directory and files will be placed in this directory periodically. I am writing a service to poll that directory and download the files for processing. I have figured...
9
by: Sheldon Cohen | last post by:
Hello, I am using c# and running a site that is on a shared host. The code in question is supposed to create a new directory that is coming out of a text box. It works fine on my computer, but...
8
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the...
3
by: Stephane | last post by:
Hi, I'm trying to use PayPal and its Instant Payment Notification. In short, when a payment is made, PayPal send a post to my server and I post it back to PayPal. I'm using WebRequest to do...
4
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
2
by: Johannes | last post by:
When you do a webrequest like: Dim objWebRequest As WebRequest = WebRequest.Create(objURI) the returned class can be httpwebrequest, ftpwebrequest or any othe descendant webrequest type that is...
6
by: matt | last post by:
hello, i am having trouble doing something. when a user triggers a certain event in my app, i need to initiate another web request to one of my other webpages, programmatically. currently, i do...
4
by: ndedhia1 | last post by:
Hi. I am writing a java program in which I want to ftp a file to another unix box. First I have to check if the directory exists in which I am ftping into and if it does not exist, I have to create...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.