从 ASP.NET MVC 应用程序中,我尝试连接两个路径,一个远程服务器路径和一个从数据库中提取的路径。我在下面表演:
string serverPath = @"\\myServer\TempFolder";
string filePath = GetPathFromDatabaseTable();
string finalPath = System.IO.Path.Combine(serverPath, filePath);
GetPathFromDatabaseTable 方法返回此字符串:
\\path\\to\\file.pdf
使用 Path.Combine 连接时,进入 finalPath 的结果是:
\\path\\to\\file.pdf
因此前缀 serverPath \myServer\TempFolder 被删除。为什么会发生?