views:

125

answers:

3

Hi,

I want to programatically create a directory on the server using ASP.NET.

I have done this using System.IO's Directory.CreateDirctory. however, the newly created folder is not accessible in the code.

after searching a bit, I came to know that the newly create folder is not included the project and hence not accessible.

Can anyone please help me out on this.

Thank You

A: 

You mention that it is not included in the project. Are you referring to the project in Visual Studio? If so, it will not show up there as it is not a listing of file system directories. It is a listing of project files as build in the proj file. You will need to add it there.

If you are referring to the application then it should be available as soon as it is successfully created.

Please let us know where your issue is happening.

Dustin Laine
hi, By referring to project, I actually meant VisualStudio project.Well, the directory is created, I checked that, however, when I try to access a file in that directory it is throwing an error for file not found. However when I manually try to access the file from the same location, i can access it.So I was wondering if there would be any security restrictions while accessing from the code behind. Have no clue whatsoever.
James
+2  A: 

OK...From your answer to my comment I think you can try this thing out:

 images.ImageUrl = "~/Images-" + ObjectName + "/Slide1.png";

Hope this helps...!!

Manish
Oh! Thanks mate, it worked!
James
Yep, it looks like the OP is attempting to set the ImageUrl to the mapped path to the image, without a slash between the folder and the image - I guess the output source would look something like: `src="c:\path-to-site\Images-ObjectNameSlide1.png"`
Zhaph - Ben Duguid
@Zhaph - Ben Duguid : Yes, that was a mistake. But still if you put that missing slash, you won't get the required image as the property itself says what it needs *`ImageUrl`*..!! It needed a URL while Jayesh was providing it an absolute path..!!
Manish
Yes, I saw that ;) hence the +1 ;)
Zhaph - Ben Duguid
Ohh...!! I thought the asker has done that +1..!! :)
Manish
Yeah it was my mistake, giving absolute pathThanks Manish.
James
A: 

Be careful when modifying the content of the web site in IIS : it detects such modifications and restarts the application immediately.

Seb