- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
您好,我正在尝试将文件复制到共享网络,但我继续收到错误消息文件名、目录名或卷标语法不正确
。有人可以请捕获我做错了什么。我的应用程序也在使用 ASP.NET MVC3 运行,谢谢!
复制代码
File.Copy(@path, @Properties.Settings.Default.SharedMappedOutput);
路径是一个参数: C:\log\12345.pdf
Properties.Settings.Default.SharedMappedOutput 路径: \\vfler_xx\evl_xx\VT\
。
我想要完成的事情:我想将文件从 Path
(文件名)复制到 SharedMappedOutput
(目录)
额外信息
编辑
我在@Steve 的帮助下更改了我的代码,但现在它说我无权访问我未指定的路径。
String dest_path = Properties.Settings.Default.SharedMappedOutput;
File.Copy(@path, Path.Combine(dest_path, Path.GetFileName(path)));
错误 访问路径“c:\windows\system32\insetsrv\12345.pdf”被拒绝
我没有指定这条路径,我不确定它为什么要访问这条路径。
链接到新问题 https://stackoverflow.com/questions/16179585/iis-acccess-to-the-path-c-windows-system32-inetsrv-12345-pdf-is-denied
谢谢。如果问题中有任何问题或误解,请告诉我。再次提前致谢。
最佳答案
File.Copy 不会将一个目录复制到另一个目录,而只是一个文件名。
您的 c:\log
似乎只是一个目录的名称,如 documentation at MSDN 所述这行不通
要复制源路径中的所有文件,您可以这样写
string destPath = Properties.Settings.Default.SharedMappedOutput;
foreach (string aFile in Directory.GetFiles(path, "*.*"))
File.Copy(aFile, Path.Combine(destPath, Path.GetFileName(aFile)));
编辑看到关于真实源名称的评论,答案仍然部分有效,因为目标也应该是文件名而不是目录。所以答案就变成了
string sourceFile = @"C:\log\12345.pdf";
string destPath = Properties.Settings.Default.SharedMappedOutput;
File.Copy(sourceFile, Path.Combine(destPath, Path.GetFileName(sourceFile)));
关于c# - 文件名、目录名或卷标语法不正确 - 映射共享网络驱动器 (ASP.NET MVC3 C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16178913/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我有实体: @Entity @Table(name = "CARDS") public class Card { @ManyToOne @JoinColumn(name = "PERSON_I
我正在尝试计算二维多边形的表面法线。我正在使用 OpenGL wiki 中的 Newell 方法来计算表面法线。 https://www.opengl.org/wiki/Calculating_a_S
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我这里有以下 XML: Visa, Mastercard, , , , 0, Discover, American Express siteonly, Buyer Pay
即将发生的 Google 政策变更迫使我们实现一个对话框,以通知欧盟用户有关 Cookie/设备标识符用于广告和分析的情况。我只想向欧盟用户显示此对话框。我不想使用额外的权限(例如 android.p
本文分享自华为云社区《华为大咖说 | 企业应用AI大模型的“道、法、术” ——道:认知篇》,作者:华为云PaaS服务小智。 本期核心观点 上车:AGI是未来5~10年内,每个人都无法回避的技
我有一个与酒精相关的网站,需要先验证年龄,然后才能让他们进入该网站。我使用 HttpModule 来执行此操作,该模块检查 cookie,如果未设置,我会将它们重定向到验证页面。我验证他们的年龄并存储
在欧盟,我们有一项法律,要求网页请求存储 cookie 的许可。我们大多数人都了解 cookie 并同意它们,但仍然被迫在任何地方明确接受它们。所以我计划编写这个附加组件(ff & chrome),它
以下在 C 和/或 C++ 中是否合法? void fn(); inline void fn() { /*Do something here*/ } 让我担心的是,第一个声明看起来暗示函数将被定义
我是一名优秀的程序员,十分优秀!