I'm using webclient in C# ASP.NET project to enable download of files to my web page visitors.
but when i compile it the errors as follows:
“/WebLoad”????????????
--------------------------------------------------------------------------------
???“g:\windows\system32\inetsrv\UDP.exe”???????
??: ???? Web ????,??????????????????,??????????????????????????
??????: System.UnauthorizedAccessException: ???“g:\windows\system32\inetsrv\UDP.exe”???????
ASP.NET ?????????????????? ASP.NET ?????????????ASP.NET ?????????????????????(??,? IIS 5 ?? {MACHINE}\ASPNET,? IIS 6 ??????)??????????? ??,?????????(??? IUSR_MACHINENAME)?????????????
???? ASP.NET ????????,?????????????,??“??”,????“??”??????“??”?????????????? ASP.NET ??,?????????????
???:
? 49: //f.Assert();
? 50:
? 51: myWebClient.DownloadFile(myStringWebResource,fileName);
? 52: //Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
? 53: //Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + System.Windows.Forms.Application.StartupPath);
???: g:\inetpub\wwwroot\webload\webform1.aspx.cs ?: 51
????:
[UnauthorizedAccessException: ???“g:\windows\system32\inetsrv\UDP.exe”???????]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +43
System.Net.WebClient.DownloadFile(String address, String fileName) +75
[WebException: ? WebClient ?????????]
System.Net.WebClient.DownloadFile(String address, String fileName) +450
WebLoad.WebForm1.Page_Load(Object sender, EventArgs e) in g:\inetpub\wwwroot\webload\webform1.aspx.cs:51
WebLoad.WebForm1.Page_Load(Object sender, EventArgs e) in g:\inetpub\wwwroot\webload\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
????: Microsoft .NET Framework ??:1.1.4322.573; ASP.NET ??:1.1.4322.573
my codes is:
string remoteUri = "http://192.168.0.5/WindowsForms/";
string fileName = "UDP.exe";
string myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
myStringWebResource = remoteUri + fileName;
string fileaccess=System.Windows.Forms.Application.StartupPath+"\\"+fileName;
//FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read,fileaccess);
//f.Assert();
myWebClient.DownloadFile(myStringWebResource,fileName);
th download file:UDP.exe that save in the visual path e:\windowsform\