I have searched google for a solution but it looks like this isn't a common issue so I can't find an answer.
I created a website in asp.net C# with a login system
I have a button that deletes the specified folder on click from my solution(I can't be more clear than this)
This folder contains files that get uploaded by the user but when it is done being used I want the user to have the ability to delete the folder through the website(not needing to go into the solution)
The code I use to do the delete is this
public Boolean deleteFolder(String directory, String FolderName)
{
directory = page.Server.MapPath(directory + "/" + FolderName);
if (Directory.Exists(directory))
{
try
{
Directory.Delete(directory, true);
}
catch (IOException)
{
Thread.Sleep(1);
Directory.Delete(directory, true);
}
}
if (Directory.Exists(directory))
{
deleteRecuring(directory);
}
return false;
}
private void deleteRecuring(String directory)
{
try
{
string[] files = Directory.GetFiles(directory);
string[] dirs = Directory.GetDirectories(directory);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
{
deleteRecuring(dir);
}
Directory.Delete(directory, false);
}
catch {}
if (File.Exists(directory))
{
Thread.Sleep(1);
}
}
The issue I have is that when I click to delete the folder and all of its contents it logs the user(who ever is logged into the website) out of the website.
I am unsure why this is happening and hoping someone could look at my code and maybe guide me to the answer and how to fix it
If this is by any means unclear, please tell me what else I am missing so I can add it in.