Permission error when creating folder through vb.net code
-
Hi, I am trying to create folders dynamically using asp.net 2005. The code that i use here is already being used in .Net 2003 and is working fine there. But when i do the same thing in .Net 2005 the following is the error that i m getting : Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. I have given write permissions to everyone for that folder still it does not work. And this is not working on my local machine itself. If anyone can suggest some solution to this. thanks, sabiha.
-
Hi, I am trying to create folders dynamically using asp.net 2005. The code that i use here is already being used in .Net 2003 and is working fine there. But when i do the same thing in .Net 2005 the following is the error that i m getting : Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. I have given write permissions to everyone for that folder still it does not work. And this is not working on my local machine itself. If anyone can suggest some solution to this. thanks, sabiha.
It's very tough to answer as you haven't provided any code that you use.
Navaneeth How to use google | Ask smart questions
-
It's very tough to answer as you haven't provided any code that you use.
Navaneeth How to use google | Ask smart questions
Here is the code that i use to create folders : MImageDirectoryName = "~/pictures/folder1" MImageDirectoryPath = Server.MapPath(MImageDirectoryName) If Dir(MImageDirectoryPath, FileAttribute.Directory) = "" Then MkDir(MImageDirectoryPath) End If The folder1 used here has read/write permissions. I feel as if the problem lies in the line server.mappath, also tried writing ../pictures/folder1, pictures/folder1 but still no use gives the same error.
-
Here is the code that i use to create folders : MImageDirectoryName = "~/pictures/folder1" MImageDirectoryPath = Server.MapPath(MImageDirectoryName) If Dir(MImageDirectoryPath, FileAttribute.Directory) = "" Then MkDir(MImageDirectoryPath) End If The folder1 used here has read/write permissions. I feel as if the problem lies in the line server.mappath, also tried writing ../pictures/folder1, pictures/folder1 but still no use gives the same error.
Have you tried to use Directory class?
Directory.CreateDirectory
should do the trick.Navaneeth How to use google | Ask smart questions
-
Have you tried to use Directory class?
Directory.CreateDirectory
should do the trick.Navaneeth How to use google | Ask smart questions
Thank you for your reply. Yes i tried using the directory class as you suggested but still the same permission issue. Actually the problem does not lie in the method we create folders but the statement that i write for getting path which is as under :- MImageDirectoryName = "../Pictures/folder1" MImageDirectoryPath = Server.MapPath(MImageDirectoryName) It gives error in the line server.mappath ..... Can you suggest anything else pls ..... thanks, sabiha.