Get directory using ASP.Net in GoDaddy

I needed to retrieve the files in a directory hosted with GoDaddy using ASP.Net C# and I got an error using Directory.GetFiles()—specifically, this error:

Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.

So, I looked around and came up with this:

Directory.GetFiles(Server.MapPath(“/yourdirectory”));

Works like a charm!

About admin