Dobry den chtel bych si udelat Uppdator ktery by si lidi stahli a nahralo jim to napr.snapshot minecraftu do appdat ale nevim jak to mam udelat
Kdyz stahnul soubor z netu viz kod
ebClient client2 = new WebClient();
client2.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client2_DownloadProgressChanged);
client2.DownloadFileCompleted += new AsyncCompletedEventHandler(client2_DownloadFileCompleted);
client2.DownloadFileAsync(new Uri("Zde dam odkud se to bude stahovat"), @"ale co zde abych ukaldal do appdata");
Tak jsem skusil jeste neco a nevim v cem je chyba stahne se to ale nepresune do appdat viz kod
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("http://assets.minecraft.net/1_4_7/minecraft.jar"), @"C:\PFiles\minecraft.jar");
}
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Hotovo nahrano");
progressBar1.Value = 0;
string sourceFile = @"C:\PFiles\minecraft.jar";
string destinationFile = @"%USERPROFILE%\AppData\Roaming\.minecraft\bin\minecraft.jar";
// To move a file or folder to a new location:
System.IO.File.Move(sourceFile, destinationFile);
// To move an entire directory. To programmatically modify or combine
// path strings, use the System.IO.Path class.
System.IO.Directory.Move(@"C:\PFiles\", @"%appdata%\.minecraft\bin\");
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
string sFormatted = string.Format("{0} of {1}", e.BytesReceived, e.TotalBytesToReceive);
Invoke(new MethodInvoker(delegate
{
progressBar1.Value = e.ProgressPercentage;
}));
}
}
}
#22Lukas @"%USERPROFILE%\AppData\Roaming\.minecraft\bin\minecraft.jar"není validní cesta. Aby byla, musel bys nahradit %USERPROFILE%, za skutečnou cestu a k tomu ti právě pomůžou výše uvedené funkce, což bys zjistil hned, kdybys je zadal do Googlu ...