public void AddOrUpdateFileInfo(FileUpload fu) { if (fu.UniqueKey == "") { return; } StorageFile sf = null; try { sf = (StorageFile)settings.First(f => f.Key == fu.UniqueKey).Value; } catch (Exception) { } if (sf != null) { sf.UploadedRanges = fu.ResponseText; } else { sf = new StorageFile(); sf.Key = fu.UniqueKey; sf.SessionId = fu.SessionId; sf.UploadUrl = fu.UploadUrl.ToString(); sf.UploadedRanges = fu.ResponseText; sf.CreatedOn = DateTime.Now; try { settings.Add(sf.Key, sf); } catch (Exception) { } } Flush(); }
void addFilesButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = FileFilter; dlg.Multiselect = true; if ((bool)dlg.ShowDialog()) { int index = 0; foreach (FileInfo file in dlg.Files) { ++index; FileUpload upload = new FileUpload(this.Dispatcher, file); upload.StatusChanged += new EventHandler(upload_StatusChanged); upload.UploadProgressChanged += new ProgressChangedEvent(upload_UploadProgressChanged); //debug upload.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(upload_Debug); callJS("onSelect", upload.SessionId, upload.Name, upload.FileLength, index, dlg.Files.Count()); files.Add(upload); } } }
public StorageFile GetFileInfo(FileUpload fu) { StorageFile sf = null; if (fu.UniqueKey != "") { try { sf = (StorageFile)settings.First(f => f.Key == fu.UniqueKey).Value; } catch (Exception) { } } return sf; }
public void DeleteFileInfo(FileUpload fu) { if (fu.UniqueKey != "") { try { settings.Remove(fu.UniqueKey); } catch (Exception) { } Flush(); } }