private string ResolveFilePath(string filePath) { if (!IsPathInMemory(filePath)) { if (filePath.StartsWith(@"file://")) { // Client sent the path in URI format, extract the local path and trim // any extraneous slashes Uri fileUri = new Uri(filePath); filePath = fileUri.LocalPath.TrimStart('/'); } // Some clients send paths with UNIX-style slashes, replace those if necessary filePath = filePath.Replace('/', '\\'); // Clients could specify paths with escaped space, [ and ] characters which .NET APIs // will not handle. These paths will get appropriately escaped just before being passed // into the PowerShell engine. filePath = PowerShellContext.UnescapePath(filePath); // Get the absolute file path filePath = Path.GetFullPath(filePath); } Logger.Write(LogLevel.Verbose, "Resolved path: " + filePath); return(filePath); }
private string ResolveFilePath(string filePath) { if (!IsPathInMemory(filePath)) { if (filePath.StartsWith(@"file://")) { // Client sent the path in URI format, extract the local path Uri fileUri = new Uri(Uri.UnescapeDataString(filePath)); filePath = fileUri.LocalPath; } // Clients could specify paths with escaped space, [ and ] characters which .NET APIs // will not handle. These paths will get appropriately escaped just before being passed // into the PowerShell engine. filePath = PowerShellContext.UnescapePath(filePath); // Get the absolute file path filePath = Path.GetFullPath(filePath); } this.logger.Write(LogLevel.Verbose, "Resolved path: " + filePath); return(filePath); }