public bool CopyFileSystemEntry(string filePath, string newParentPath) { if ((filePath == null) || (newParentPath == null)) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidParameters); var ph = new PathHelper(filePath); var dir = ph.GetDirectoryName(); var file = ph.GetFileName(); if (dir.Length == 0) dir = "/"; var container = GetFolder(dir); var fsEntry = GetFileSystemObject(file, container); var newParent = GetFolder(newParentPath); return CopyFileSystemEntry(fsEntry, newParent); }
/// <summary> /// This mehtod allows to perform a server side renam operation which is basicly the same /// then a move operation in the same directory /// </summary> /// <param name="filePath">File or directory which has to be renamed</param> /// <param name="newName">The new name of the targeted filesystem object</param> /// <returns></returns> public bool RenameFileSystemEntry(String filePath, String newName) { // check parameter if ((filePath == null) || (newName == null)) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidParameters); // get path and filename var ph = new PathHelper(filePath); String dir = ph.GetDirectoryName(); String file = ph.GetFileName(); // check if we are in root if (dir.Length == 0) dir = "/"; // get parent container ICloudDirectoryEntry container = GetFolder(dir); // get filesystem entry ICloudFileSystemEntry fsEntry = GetFileSystemObject(file, container); // rename file return RenameFileSystemEntry(fsEntry, newName); }
/// <summary> /// This method creates a new file object in the cloud storage. Use the GetContentStream method to /// get a .net stream which usable in the same way then local stream are usable /// </summary> /// <param name="filePath">The name of the targeted file</param> /// <returns></returns> public ICloudFileSystemEntry CreateFile(String filePath) { // check parameter if (filePath == null) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidParameters); // get path and filename var ph = new PathHelper(filePath); String dir = ph.GetDirectoryName(); String file = ph.GetFileName(); // check if we are in root if (dir.Length == 0) dir = "/"; // get parent container ICloudDirectoryEntry container = GetFolder(dir); // rename file return CreateFile(container, file); }
/// <summary> /// This function allows to download a specific file /// </summary> /// <param name="filePath"></param> /// <param name="targetPath"></param> /// <param name="delProgress"></param> /// <returns></returns> public void DownloadFile(String filePath, String targetPath, FileOperationProgressChanged delProgress) { // check parameter if (filePath == null || targetPath == null) throw new SharpBoxException(SharpBoxErrorCodes.ErrorInvalidParameters); // get path and filename var ph = new PathHelper(filePath); String dir = ph.GetDirectoryName(); String file = ph.GetFileName(); // check if we are in root if (dir.Length == 0) dir = "/"; // get parent container ICloudDirectoryEntry container = GetFolder(dir); // download file DownloadFile(container, file, targetPath, delProgress); }