Last post Oct 17, 2010 09:18 AM by Mikee1504
Oct 17, 2010 07:57 AM|Mikee1504|LINK
I have noticed today that when you create a directory in code in a web application the resulting folder structure is not created in the solution explorer (It is fine on disk and app can still access all the files)
I am not sure if there is a setting that I am missing or is this a bug?
Steps to reproduce
Create a new C# web application in VS 2010.
Create a new web page (Default.aspx) and add a file upload control and a button.
on the click event on the button add the following code
String ImageUrlPath = "/Media/Photo/";
Directory.CreateDirectory(Request.PhysicalApplicationPath + ImageUrlPath);
string FileName = FileUpload1.FileName.ToString().Replace(" ", "");
FileUpload1.SaveAs(Request.PhysicalApplicationPath + ImageUrlPath + FileName);
When the form posts back refresh the solution explorer and the new directory does not appear.
Check your file system and the file will be there.
Not a massive issue but frustrating. Any guidance would be appreciated
Oct 17, 2010 08:27 AM|XIII|LINK
in the solution explorer, at the top, there's a button which has as tooltip:
Show all files. Make sure that's on and try again, then refresh.
A web application behaves differently than a website project type (which is file based): it's a project focussed approach and if something's not in the project and you didn't turn the Show all files feature on (which is not the case by default) you won't
see it as the newly created folder doesn't make part of your project file.
Oct 17, 2010 09:18 AM|Mikee1504|LINK
I hate it when I miss the easy things!!