Beispiel #1
0
 public static TransferQueue CreateDownloadQueue(TransferClient client, int id, string saveName, long length)
 {
     try
     {
         var queue = new TransferQueue();
         queue.Filename = Path.GetFileName(saveName);
         queue.Client   = client;
         queue.Type     = QueueType.Download;
         queue.FS       = new FileStream(saveName, FileMode.Create);
         queue.FS.SetLength(length);
         queue.Length = length;
         queue.Id     = id;
         return(queue);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Beispiel #2
0
 public static TransferQueue CreateUploadQueue(TransferClient client, string fileName)
 {
     try
     {
         var queue = new TransferQueue();
         queue.Filename            = fileName;
         queue.Client              = client;
         queue.Type                = QueueType.Upload;
         queue.FS                  = new FileStream(fileName, FileMode.Open);
         queue.Thread              = new Thread(new ParameterizedThreadStart(transferProc));
         queue.Thread.IsBackground = true;
         queue.Id                  = App.Random.Next();
         queue.Length              = queue.FS.Length;
         return(queue);
     }
     catch (Exception)
     {
         return(null);
     }
 }