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 { return(null); } }
public static TransferQueue CreateUploadQueue(TransferClient client, string fileNme) { try { var queue = new TransferQueue(); queue.FileName = Path.GetFileName(fileNme); queue.Client = client; queue.Type = QueueType.Upload; queue.FS = new FileStream(fileNme, FileMode.Open); queue.Thread = new Thread(new ParameterizedThreadStart(transferProc)); queue.Thread.IsBackground = true; queue.ID = Program.Rand.Next(); queue.Length = queue.FS.Length; return(queue); } catch { return(null); } }
public static TransferQueue CreateDownloadQueue(TransferClient client, int id, string saveName, long length) { try { //Same as above with some changes. var queue = new TransferQueue(); queue.Filename = Path.GetFileName(saveName); queue.Client = client; queue.Type = QueueType.Download; //Create our file stream for writing. queue.FS = new FileStream(saveName, FileMode.Create); //Fill the stream will 0 bytes based on the real size. So we can index write. queue.FS.SetLength(length); queue.Length = length; //Instead of generating an ID, we will set the ID that has been sent. queue.ID = id; return(queue); } catch { return(null); } }