示例#1
0
 public static TransferQueue CreateDownloadQueue(TransferClient client, int id, string savename, long lenght)
 {
     try
     {
         var queu = new TransferQueue();
         queu.FileName = Path.GetFileName(savename);
         queu.Client   = client;
         queu.Type     = QueueType.Download;
         queu.FS       = new FileStream(savename, FileMode.Create);
         queu.FS.SetLength(lenght);
         queu.Length = lenght;
         queu.ID     = id;
         return(queu);
     }
     catch
     {
         return(null);
     }
 }
示例#2
0
 public static TransferQueue CreateUploadQueue(TransferClient client, string filename)
 {
     try
     {
         var queu = new TransferQueue();
         queu.FileName            = Path.GetFileName(filename);
         queu.Client              = client;
         queu.Type                = QueueType.Upload;
         queu.FS                  = new FileStream(filename, FileMode.Open);
         queu.Thread              = new Thread(new ParameterizedThreadStart(transferProc));
         queu.Thread.IsBackground = true;
         queu.ID                  = App.Rand.Next();
         queu.Length              = queu.FS.Length;
         return(queu);
     }
     catch
     {
         return(null);
     }
 }