给定的路径的格式不支持误差File.copy()方法 [英] The given path's format is not supported error with File.copy() method

查看:885
本文介绍了给定的路径的格式不支持误差File.copy()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从本地计算机的文件拷贝到其他机器的本地网络内,通过file.copy()在C#中的方法,我的错误说法,不支持给定路径的格式遇到

我使用下面的语法

  File.Copy(@C:\\ TEMP \\ sample.txt的@\\\\ DEMO-PC \\ D:\\ DummyFolder \\ sample.txt的,真正的);


解决方案

尝试用一个美元符号代替冒号:

  File.Copy(@C:\\ TEMP \\ sample.txt的@\\\\ DEMO-PC \\ D $ \\ DummyFolder \\ sample.txt的,真正的);

修改

在':'字符在Windows路径特殊的地位;它不是合法的文件共享的名称使用它。在$字符也有一个特殊的地位:它是用来指定隐藏的共享。 Windows会自动创建一个计算机上的每个驱动器隐藏的文件共享;省略冒号,因为它是不合法的,并添加$来隐藏共享。

有关详情请参阅此知识库文章: http://support.microsoft.com/kb/314984

When i try to copy the file from local machine to other machine within the local network, through file.copy() method in c#, i am encountered with the error saying, The given path's format is not supported

I am using the following syntax

File.Copy(@"C:\temp\sample.txt", @"\\DEMO-PC\D:\DummyFolder\sample.txt", true);

解决方案

Try replacing the colon with a dollar sign:

File.Copy(@"C:\temp\sample.txt", @"\\DEMO-PC\D$\DummyFolder\sample.txt", true);

EDIT

The ':' character has a special status in Windows paths; it's not legal to use it in the name of a file share. The '$' character also has a special status: it is used to designate hidden shares. Windows automatically creates hidden file shares for each drive on a computer; omitting the colon because it's not legal, and adding the '$' to hide the share.

See this knowledge base article for more information: http://support.microsoft.com/kb/314984

这篇关于给定的路径的格式不支持误差File.copy()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆