Everytime I create a new property for accessing our web site, I want to create a directory for it to store related files that will be uploaded. See the below code: // Create the GUID for the new property's ID Guid g = Utilities.getGUID(); // Create a new directory on the server for the files related to the property try { string path = Server.MapPath("\\Files") + g.ToString(); DirectoryInfo dir = Directory.CreateDirectory(path); } catch (UnauthorizedAccessException ex) { Utilities.LogError(ex); } The code doesn't give an error or produce a new directory... I'm very stumped. Could this be permissions related?
Could be permissions, the ASP.NET user, but for sure add some generic error trapping for the entire page: http://www.codeproject.com/aspnet/ErrorHandlingASPNET.asp
you should always get an error if there's some problem. I think your code may have just trapped the error. Bruce DiscountASP.NET www.DiscountASP.NET
try adding another general catch block below your specific one and see if anything pops up. catch (UnauthorizedAccessException ex) { Utilities.LogError(ex); } catch (Exception ex) { Systems.Diagnostics.Debug.Assert(false,"Catch my silent error here!"); }
Your path is incorrect. Try : Guid g = Utilities.getGUID(); // Create a new directory on the server for the files related to the property try { string path = MapPath('Files') +'\\'+ g.ToString(); DirectoryInfo dir = Directory.CreateDirectory(path); } catch (UnauthorizedAccessException ex) { Utilities.LogError(ex); } Vikram DiscountASP.NET www.DiscountASP.NET