c# 不支持给定路径的格式。 UNC路径

c# The given path's format is not supported. UNC Path

我正在尝试从远程服务器访问和下载 bak 文件,但一直收到错误 "The given path's format is not supported." 我在下面使用的代码:

string uncPath = Server.MapPath(Path.Combine(@"\TSTSVR\Users\temp_databaseBackups_000kfkf000", 
  string.Format("{0}-{1}.bak", ddlDatabases.SelectedValue, DateTime.Now.ToString("yyyy-MM-dd"))));

//download
WebClient webClient = new WebClient();
webClient.DownloadFile(uncPath, ddlDatabases.SelectedValue + "-" + DateTime.Now.ToString("MM-dd-yyyy:hh:mm"));

我在 DownloadFile 行收到错误。我是否声明 UNC 路径错误?该文件夹在服务器上,我设置了对具有写入权限的所有人的访问权限。

如果远程机器在 Windows 控制下工作,则路径中不允许出现冒号。

在大家正确方向的一些提示的帮助下,我用以下代码解决了这个问题:

string uncPath = Path.Combine(@"\TSTSVR\Users\temp_databaseBackups_000kfkf000",
  string.Format("{0}-{1}.bak", ddlDatabases.SelectedValue, DateTime.Now.ToString("yyyy-MM-dd")));

//download
Response.ContentType = "bak";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + ddlDatabases.SelectedValue + "-" + DateTime.Now.ToString("MM-dd-yyyy:hh:mm") + "\"");

Response.TransmitFile(uncPath);
Response.End();

程序现在将从远程服务器下载所需的文件。