Avatar of medsoos
medsoos
 asked on

Workaround for Directory.GetDirectories on restrictive shared host

Hi, I'm trying to upload an asp.net site that I didn't write to a shared host - GoDaddy.com. Apparently because of their restrictive security policies I am unable to read subdirectories within my own site. The code it's balking on is: Directory.GetDirectories - please see below. Is there any other way to get this information or does anyone have a way around this problem? GoDaddy's technical support knows very little about asp.net and can't help.

Thanks.


lsubbdirs = Directory.GetDirectories(ltargdirr);
		lprevfold = "STARTING FOLDER NAME" ;

		foreach(string ldirrname in lsubbdirs) {
			ldirrfold = ldirrname.Substring(12) ;
			if (ldirrfold.IndexOf("-XXX-")>0){
				if (ldirrfold.Substring(0,5)!= lprevfold.Substring(0,5)){
					foldlist.Items.Add(new ListItem("-------------------------","")) ;
					foldlist.Items.Add(new ListItem(ldirrfold,ldirrfold)) ;
				}else{
					foldlist.Items.Add(new ListItem(ldirrfold,ldirrfold)) ;
				}//endif
			}//endif
			lprevfold = ldirrfold ;
		}//endfor

Open in new window

NetworkingASP.NET

Avatar of undefined
Last Comment
lunadl

8/22/2022 - Mon
Bob Learned

If you don't have access to the folders, there isn't any workaround that I know of.  What do you need the folder access for?
medsoos

ASKER
I think the problem is more related to GoDaddy not allowing the Directory.GetDirectories method. They only allow medium instead of full access for asp. The program builds a list of directories, subdirectories and files for users in a content management system. I think I need to switch providers.
lunadl

This is the code we use for the same behavior on GoDaddy. It has been up for a long time and I recall either recoding to this method or asking them to bump permissions. That is a second option... Third option(if possible) might be get a new host

PS
bidDocsGV is a gridview
Dim theBidPath As String = "./files/bid" & Request.QueryString("Bid").ToString()
      
      If Directory.Exists(Server.MapPath(theBidPath)) Then
        'if it is there, write out the contents to the gridview
        Dim bidDocsInfo As New DirectoryInfo(Server.MapPath(theBidPath))
        bidDocsGV.DataSource = bidDocsInfo.GetFiles()
        bidDocsGV.DataBind()
      Else

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
medsoos

ASKER
Lunadl,
I'll try this tonight and let you know. May have to move anyway though, as not sure what other disallowed code this project contains. Might as well switch to a full access provider while I can.
thanks.
 
medsoos

ASKER
I was able to work around this another way, by just hand-populating an array. But then as soon as that was fixed, came across another forbidden method. GoDaddy will not change their policies and I don't know how many more landmines exist in the hundreds of thousands of lines of code, so we're moving to a different host. Thanks for the help.
ASKER CERTIFIED SOLUTION
lunadl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.