/// <summary> /// Every mobile device has 1 or more places where data & programs can be stored. At the very least this includes /// main memory, but it can potentially have 1 or more removable storage cards and 1 or more built-in storage areas. /// This method examines the device to see what's currently available. /// </summary> /// <param name="rapi"></param> /// <param name="forDisplay"></param> // This parameter simply determines how Main Memory will be stored in the return arraylist /// <returns>An array of the storage locations available.</returns> public static ArrayList GetStorageLocations(RAPI rapi, bool forDisplay) { // This procedure utilizes the fact that the RAPIFileAttributes enum contains these values: // 16 - Directory // 256 - Temporary const int tempDir = 272; ArrayList locationList = new ArrayList(); // Initialize the array we're going to pass back if (forDisplay) { locationList.Add("Main Memory"); } else { locationList.Add("\\"); } // Now from the root directory, see what else is present. FileList folderList = rapi.EnumFiles("\\*.*"); foreach (FileInformation folderInfo in folderList) { string folder = folderInfo.FileName; if ((folderInfo.FileAttributes & tempDir) == tempDir) // Only add those items that are both Directories { locationList.Add(folder); // and "Temporary" - ie. storage card & built-in storage. } } return(locationList); }
/// <summary> /// Ищем файлы по маске и копируем на локальный компьютер /// </summary> /// <param name="localPath">Полный путь к папке на локальном компьютере</param> /// <param name="remoteFileName">Путь на устройстве с маской поиска</param> /// <returns>TRUE - копирование без ошибок, FALSE - если возникла хоть одна ошибка</returns> public bool CopyFromDeviceList(String localPath, String remoteFileName) { string errors = string.Empty; bool res = true; try { FileList files = m_RAPI.EnumFiles(remoteFileName); foreach (FileInformation item in files) { try { m_RAPI.CopyFileFromDevice(mLocalPath + item.FileName, mRemotePath + item.FileName, true); m_RAPI.DeleteDeviceFile(mRemotePath + item.FileName); } catch (Exception exc) { errors = String.Format("{0}\r\n{1}", errors, exc.Message); res = false; } } if (!res) { lbStatus.Text = errors; } } catch (Exception ex) { lbStatus.Text = ex.Message; res = false; } return(res); }
/// <summary> /// Retrieves the list of files in a specified folder. Returns this information: /// - Filename /// - File size /// - File date & time (various types) /// </summary> /// <param name="rapi"></param> /// <param name="path"></param> /// <param name="fileFilter"></param> /// <returns></returns> public static FileList GetFolderContents(RAPI rapi, string path, string fileFilter) { path = Tools.EnsureFullPath(path); if ((fileFilter == null) || (fileFilter == "")) { fileFilter = "*.*"; } return(rapi.EnumFiles(path + fileFilter)); }
private void btnDelete_Click(object sender, EventArgs e) { string[] AllSelected = ExtractNames().Split(new string[] { "!!" }, StringSplitOptions.None); try { if (PublicClass.currentInstrument == "Impaq-Benstone" || PublicClass.currentInstrument == "FieldPaq2") { if (objConnToDvc.DevicePresent) { if (MessageBox.Show("Do You Want To Delete The Selected Databases", "Database Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FileList instname = objConnToDvc.EnumFiles("Storage Card\\*.*"); for (int i = 0; i < AllSelected.Length - 1; i++) { if (objConnToDvc.DeviceFileExists("Storage Card\\" + instname[0].FileName + "\\DataCollector\\Data\\" + AllSelected[i])) { objConnToDvc.DeleteDeviceFile("Storage Card\\" + instname[0].FileName + "\\DataCollector\\Data\\" + AllSelected[i]); } } MessageBox.Show("Route Deleted Successully"); GetInfo(); } } else { MessageBox.Show("Device Not Connected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { DIDelete(AllSelected[0], Convert.ToString(lbPrsntDataBss.SelectedIndex), RouteNumbers); MessageBox.Show("Route Deleted Successully"); } } catch { } }