G
Guest
I have noticed that the Directory.Move removes the session as soon as the
next Response.Redirect is done. It also appears that .Net framework
constantly monitors all the directories below the root and invalidates the
inproc session. Can this be caught as an exception and ignored.
In the meantime, I have figured out a variant of Directory.Move that seems
to solve this problem.
===========================================
public static bool MoveFolder(string sourcePath, string destPath)
{
FileInfo fi;
DirectoryInfo di;
string destFileName;
String strDesSubDirectory;
try
{
if (
(!Directory.Exists(sourcePath)) ||
(Directory.Exists(destPath))
)
{
return false;
}
Directory.CreateDirectory(destPath);
// Copy the Files
foreach(string srcFileName in Directory.GetFiles(sourcePath))
{
fi = new FileInfo(srcFileName);
destFileName = destPath + @"/" + fi.Name;
File.Move(srcFileName, destFileName);
}
// Create the Directories
foreach (string strSrcSubDirectory in
Directory.GetDirectories(sourcePath))
{
di = new DirectoryInfo(strSrcSubDirectory);
strDesSubDirectory = destPath+ @"\" + di.Name;
return MoveFolder(strSrcSubDirectory, strDesSubDirectory);
}
Directory.Delete(sourcePath, true);
}
catch
{
return false;
}
return true;
}
=============================================
next Response.Redirect is done. It also appears that .Net framework
constantly monitors all the directories below the root and invalidates the
inproc session. Can this be caught as an exception and ignored.
In the meantime, I have figured out a variant of Directory.Move that seems
to solve this problem.
===========================================
public static bool MoveFolder(string sourcePath, string destPath)
{
FileInfo fi;
DirectoryInfo di;
string destFileName;
String strDesSubDirectory;
try
{
if (
(!Directory.Exists(sourcePath)) ||
(Directory.Exists(destPath))
)
{
return false;
}
Directory.CreateDirectory(destPath);
// Copy the Files
foreach(string srcFileName in Directory.GetFiles(sourcePath))
{
fi = new FileInfo(srcFileName);
destFileName = destPath + @"/" + fi.Name;
File.Move(srcFileName, destFileName);
}
// Create the Directories
foreach (string strSrcSubDirectory in
Directory.GetDirectories(sourcePath))
{
di = new DirectoryInfo(strSrcSubDirectory);
strDesSubDirectory = destPath+ @"\" + di.Name;
return MoveFolder(strSrcSubDirectory, strDesSubDirectory);
}
Directory.Delete(sourcePath, true);
}
catch
{
return false;
}
return true;
}
=============================================