Download Error (Web Client)

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I am trying to download a file and get a current error:

Download(...): Unable to download file

Access to the path 'C:\Temp\aaa.zip' is denied.

While I was downloading with this code:
_webClient = new WebClient();
_webClient.DownloadFile(httpPath, filePath);


Another thing is that I am doing this action for few threads and each
thread creates it's own filePath (but I don't think it's related to it).

How to avoid this error?

Thank you!
 
Does C:\temp\
already exist?

If not, experiment with making the directory before downloading.

Who is trying to save the file?

Here is some VERY CRAPPY code to identify the "who".



private string FindIIdentity()

{

try

{

//'Dim user As WindowsPrincipal =
CType(System.Threading.Thread.CurrentPrincipal, WindowsPrincipal)

//'Dim ident As IIdentity = user.Identity

string returnValue = string.Empty;



WindowsIdentity ident = WindowsIdentity.GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environment.MachineName;

}

catch (Exception ex)

{

Conditionals.Trace.WriteMessage(ex.Message);

}

return returnValue;

}



catch (Exception ex)

{

Conditionals.Trace.WriteMessage(ex.Message);

return "Error Finding Identity";

}

}
 
Back
Top