首页 > 解决方案 > 如何使用 Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 连接到外部服务器

问题描述

以下代码是我试图用来连接到外部服务器并进入 AppData 文件夹中的子目录的代码。

string targetPath = @"\\externalServer\" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Litera\\Customize";

在单步执行程序时,它来到第 16 行,但无法说明“不支持给定路径的格式”。但是,destFile 显示“\\externalServer\C:\Users\username\AppData\Roaming\Litera\Customize\Customize.xml”。对我来说,该程序正在找到我想要的路径。有人可以帮我解决这个问题吗?

File.Copy(sourceFile, destFile, true);

标签: c#environment-variables

解决方案


推荐阅读