C# ile dosya indirme kodu neden hata veriyor?

smt55

Hectopat
Katılım
27 Kasım 2019
Mesajlar
1.257
Çözümler
2
C#:
        private void button1_Click(object sender, EventArgs e)
        {
            string W_Dizin = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Roaming\.minecraft\versions";
            string W_SiteAdresi = ".torrent";
            WebClient W_Client = new WebClient();
            W_Client.DownloadFile(W_SiteAdresi, W_Dizin);
        }
 
C#:
        private void button1_Click(object sender, EventArgs e)
        {
            string W_Dizin = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Roaming\.minecraft\versions";
            string W_SiteAdresi = ".torrent";
            WebClient W_Client = new WebClient();
            W_Client.DownloadFile(W_SiteAdresi, W_Dizin);
        }
Hata nedir?
 
C#:
System.Net.WebException
  HResult=0x80131509
  Message=An exception occurred during a WebClient request.
  Source=System
  StackTrace:
   at System.Net.WebClient.DownloadFile(Uri address, String fileName)
   at System.Net.WebClient.DownloadFile(String address, String fileName)
   at USERNAME_TEST_PROJECT.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Samet\source\repos\USERNAME TEST PROJECT\USERNAME TEST PROJECT\Form1.cs:line 26
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at USERNAME_TEST_PROJECT.Program.Main() in C:\Users\Samet\source\repos\USERNAME TEST PROJECT\USERNAME TEST PROJECT\Program.cs:line 19

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Samet\AppData\Roaming\Roaming\.minecraft\versions'.
1658659260247.png
 
Bahsettiğiniz dosya yolunu sistem bulamamış.

Kod bloğundaki path için @‘ten sonraki Roaming’i silip deneyin.

Kod:
string W_Dizin = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\versions";
 
Bahsettiğiniz dosya yolunu sistem bulamamış.

Kod bloğundaki path için @‘ten sonraki Roaming’i silip deneyin.

Kod:
string W_Dizin = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\versions";
Aga yine hata verdi




System.Net.WebException
HResult=0x80131509
Message=An exception occurred during a WebClient request.
Source=System
StackTrace:
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at USERNAME_TEST_PROJECT.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Samet\source\repos\USERNAME TEST PROJECT\USERNAME TEST PROJECT\Form1.cs:line 26
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at USERNAME_TEST_PROJECT.Program.Main() in C:\Users\Samet\source\repos\USERNAME TEST PROJECT\USERNAME TEST PROJECT\Program.cs:line 19

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
UnauthorizedAccessException: Access to the path 'C:\Users\Samet\AppData\Roaming\.minecraft\versions' is denied.


1658675535331.png
 
Son düzenleme:

Yeni konular

Yeni mesajlar

Geri
Yukarı