I want to download some files and execute them in the %temp%
folder but I get System.UnauthorizedAccessException
when I try to run it:
Exceção Sem Tratamento: System.Net.WebException: Exceção durante uma solicitação do WebClient. ---> System.UnauthorizedAccessException: O acesso ao caminho 'C:\Users\Muni\AppData\Local\Temp' foi negado. em System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
em System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
em System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) em System.Net.WebClient.DownloadFile(Uri address, String fileName) --- Fim do rastreamento de pilha de exceções internas --- em System.Net.WebClient.DownloadFile(Uri address, String fileName)
em System.Net.WebClient.DownloadFile(String address, String fileName) em encrypt.Program.Main(String[] args) na C:\Users\Muni\source\repos\encrypt\encrypt\Program.cs
try
{
string name = Environment.UserName;
WebClient Client = new WebClient();
string temp = "C:\\Users\\" + name + "\\AppData\\Local\\Temp";
Client.DownloadFile("LINK", temp);
}
catch
{
return;
}