/// <summary> /// Get file path /// </summary> /// <param name="relativePath">Relative file path</param> /// <returns>Return the file full path</returns> public string GetFilePath(string relativePath) { if (string.IsNullOrWhiteSpace(relativePath)) { return(string.Empty); } if (RootPaths.IsNullOrEmpty()) { return(relativePath); } var rootPath = dataSelectionProvider.Get(PathSelectMode); string fullPath = Path.Combine(rootPath, relativePath); return(fullPath.Replace("\\", "/")); }
/// <summary> /// get file access path with random /// </summary> /// <param name="fileRelativePath">relative file path</param> /// <returns></returns> public string GetFilePath(string fileRelativePath) { if (string.IsNullOrWhiteSpace(fileRelativePath)) { return(string.Empty); } if (RootPaths.IsNullOrEmpty()) { return(fileRelativePath); } #region get root path string rootPath = string.Empty; int rootCount = RootPaths.Count; if (rootCount == 1) { rootPath = RootPaths[0]; } else { switch (PathPattern) { case FilePathPattern.Random: var random = new Random(); int ranIndex = random.Next(0, rootCount); rootPath = RootPaths[ranIndex]; break; } } #endregion string fullPath = Path.Combine(rootPath, fileRelativePath); fullPath = fullPath.Replace("\\", "/"); return(fullPath); }