Link to home
Start Free TrialLog in
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

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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?
Avatar of medsoos
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.
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

Avatar of 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.
 
Avatar of 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
Avatar of lunadl
lunadl
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial