944,103 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4965
  • ASP.NET RSS
May 24th, 2007
0

How to set the path for directory

Expand Post »
hi am developing an application to upload images to gridview which i have completed ,now i need to create directories and subdirectories to upload the images according to their type i have written a class to read all directories like
public Classname[] Getdirectories(string name)
{
string basepath=System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPAth +"images"+"/"+name;
string[] files=Directory.GetDirectories(basepath);
}
this coding was working only for the first set of subdirectories
but on further read it gives an error like
Could not find a part of the path 'C:\Documents and Settings\ApplicationName\images\Sub'.


This is because ,a directory name is missing between the ' images' folder and 'Sub' Folder

i changed the coding like
String basepath=System.Web.Hosting.HostingEnvironment.Mappath(name);

but it gives me an error like
The relative virtual path 'Directoryname' is not allowed here
can anyone help me on this regard on how to set the path for the directory in oder to read them dynamically

plz help me on this regard
Shruthi
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shruthi_R is offline Offline
12 posts
since Apr 2007
May 24th, 2007
0

Re: How to set the path for directory

you get the error probably, inside your folder dun have "sub" folder name. you need to check it, if didnt found the folder, u need create a new folder.

based on the code, i didnt found any coding that create a new folder when the system didnt found ur folder.

hope it can help u
Reputation Points: 10
Solved Threads: 2
Newbie Poster
kokkee is offline Offline
20 posts
since May 2007
Oct 6th, 2011
0

Hi..

hi..
first create a Directory using path.getfilename
and create directory if exits then create a folder inside the directory and then save the images inside the folder and save the path in database..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dehni is offline Offline
1 posts
since Oct 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: MVC Controller Action to Receive PK in VB
Next Thread in ASP.NET Forum Timeline: Error Too many characters in character literal





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC