File installation / copying system

4

How to use the items

SortedDictionary
File.WriteAllBytes

To start or complete a process of installing files and folders to your computer.

Ex:

List of files:

void AlocarArquivos(){
var arquivo_e_pasta = new SortedDictionary<string, byte[]>();
arquivo_e_pasta.Add(@"\bin32\dedicated.exe", Properties.Resources.bin32_dedicated);
arquivos_e_pastas.Add(@"\sdk\player.df", Properties.Resources.PLAYER_DF_BTS);
}

And then go one by one applying this:

var enum0 = arquivos_e_pastas.GetEnumerator();
while(enum0.MoveNext()){
    File.WriteAllBytes(enum0.Current.Key, enum0.Current.Value);
}

But only taking the installation progress by applying Thread.Sleep without crashing the application.

    
asked by anonymous 11.07.2015 / 20:27

1 answer

0

How about creating a new Thread for this operation?

 new System.Threading.Thread((enum) => {
//Converta a enum para o objeto de sua preferencia...
var Enum = (var)enum;
while(Enum.MoveNext()){
    File.WriteAllBytes(Enum.Current.Key, Enum.Current.Value);
}}).Start(enum0);

In this algorithm will start a task on a secondary thread, when executing this command the process will be done and the main Thread (your program) will continue to run ... unfortunately the problem of this is that the program can start before this thread execute the algorithm ... (In this case I recommend making a wait algorithm in the Main class, before starting the main form ...)

    
16.06.2016 / 08:36