Hi All,
I'm experiencing an error in my code that i'm struggling to find a solution to.
I have an internal web application that needs to move some files around on our internal network. The files in question are numerous and fairly large, approx 1000 - 3000 files that are all in the range of 30Mb each.
As I do not want to block the UI thread I wish to perform this operation asynchronously.
The problem I am having is that I receive the error "
request is not available in this context
" when performing any file/folder operations after calling the begin invoke method. The method works perfectly well when not being called by begin invoke, i.e. not asynchronously.
So, for example, I have to check that the directory I am moving the files into is actually there and if not I will create it. The code to get / create the directory is as follows:
DirectoryInfo importDirectory = new DirectoryInfo(required folder path);
if (!backupLocation.Exists)
{
try
{
....try to create directory
}
catch (Exception Ex)
{
return Ex error details;
}
}
The code is running in .net 4 and hosted in IIS7. Running this code asynchronously throws the error I mention on the first line, i.e.
DirectoryInfo importDirectory = new DirectoryInfo(required folder path);.
Can anyone give me any ideas of what I need to do?
Thanks
Kev