public void g() { int op = (int)settings["trigger"]; if (k < 5) { System.Diagnostics.Debug.WriteLine("getting clips"); if (op == 0) { uploadService.GetFileByName("B" + sel[k], this); } else { uploadService.GetFileByName("H" + sel[k], this); } } else if (k == 5) { if (i == 5) { B(true); System.Diagnostics.Debug.WriteLine("got all c"); } } }
//Pre: File name //Post: Bool for whether file exists returned //Description: This method checks whether the specified file exists on the storage. public static bool CheckFileExists(string fileName) { bool exists = true; //The library throws an exception if the file does not exist, so I try to get the file and if an exception is thrown it doesn't exist try { Upload fileList = uploadService.GetFileByName(fileName); } catch (App42NotFoundException exp) { exists = false; Console.WriteLine(exp.Message); } return(exists); }
void OnGUI() { if (Time.time % 2 < 1) { success = callBack.getResult(); } // For Setting Up ResponseBox. GUI.TextArea(new Rect(10, 5, 1000, 175), success); //===================================**************========================================= if (GUI.Button(new Rect(50, 200, 200, 30), "UploadFile")) { uploadService = sp.BuildUploadService(); // Initializing UploadService. uploadService.UploadFile(cons.fileName, cons.filePath, UploadFileType.IMAGE, cons.description, callBack); } //===================================**************========================================= if (GUI.Button(new Rect(260, 200, 200, 30), "GetFileByName")) { uploadService = sp.BuildUploadService(); // Initializing UploadService. uploadService.GetFileByName(cons.fileName, callBack); } //===================================**************========================================= if (GUI.Button(new Rect(470, 200, 200, 30), "UploadFileForUser")) { uploadService = sp.BuildUploadService(); // Initializing UploadService. uploadService.UploadFileForUser(cons.fileName, cons.userName, cons.filePath, UploadFileType.IMAGE, cons.description, callBack); } //===================================**************========================================= if (GUI.Button(new Rect(680, 200, 200, 30), "UploadFileStream")) { uploadService = sp.BuildUploadService(); // Initializing UploadService. Stream stream = new FileStream(cons.filePath, FileMode.Open); uploadService.UploadFile(cons.fileName, stream, UploadFileType.IMAGE, cons.description, callBack); } }
public bool DownloadFile(string filePath, string fileName) { //If a downloaded version of the file currently exists if (File.Exists(filePath)) { //Deletes the downloaded version of the file File.Delete(filePath); } //Tries to download the file try { //A client is created to download the file using a URL using (var client = new WebClient()) { //Every file with the same name of the file that is being looked for is retrieved upload = uploadService.GetFileByName(fileName); IList <Upload.File> fileList = upload.GetFileList(); //Loop for every file in the file list for (int i = 0; i < fileList.Count(); i++) { //The current file is downloaded using it's url and the name it is stored as client.DownloadFile(fileList[i].GetUrl(), fileName); } } //Returns that the file was downloaded return(true); } //If there are any exceptions catch { //Returns that the file was not downloaded return(false); } }
private void GetFileByName_Click(object sender, RoutedEventArgs e) { uploadService.GetFileByName(Constants.fileName1, this); }