将文件复制到共享文件夹的另一台计算机上

编程入门 行业动态 更新时间:2024-10-28 12:21:36
本文介绍了将文件复制到共享文件夹的另一台计算机上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将文件复制到映射的网络位置。 如果我尝试做手工一切工作正常。

I am trying copy file to mapped network location. If I try to do it manually everything is working OK.

通过运行以下code我没有得到任何异常,但我没有得到code在需要的位置。

By running following code I don't get any exceptions but I not get the code at the needed location.

string _sharedLocation = @"C:\Users\pddd\AppData\Roaming\Microsoft\Windows\Network Shortcuts\system-tests"; if (Directory.Exists(_sharedLocation) && File.Exists(@"c:\\Automation\\Tests\\Test1\\events.json")) { File.Copy(@"c:\\Automation\\Tests\\Test1\\events.json", Path.Combine(_sharedLocation, "events11.json"), true); }

与该问题的任何建议。

Any suggestions with that issue.

推荐答案

在看 _SharedLocation 变量,它是在位置:... \的Windows \网络快捷键\ ...

looking at the _SharedLocation variable, it's on location: "...\Windows\Network Shortcuts\..."

我只是猜测这里,但你特林引用快捷方式到网络文件夹,而不是一个网络文件夹?

I'm just guessing here, but are you tring to refer to a shortcut to a network folder, rather than a network folder?

这不会有任何效果:

File.Copy(myOriginalFile, "C:\...\MyShortcutToANetworkFolder\myFile.txt");

为什么不呢?因为一个快捷方式基本上是一个的文件的,不是的文件夹的(它比这更复杂,但我保持简单的参数的缘故)。你不能把一个文件(或其他东西)变成快捷方式。您可以使用快捷键唯一要做的就是打开它。

Why not? Because a shortcut is basically a file, not a folder (it's more complicated than that, but I'm keeping it simple for argument's sake). You cannot put a file (or anything else) into a shortcut. The only thing you can do with a shortcut is open it.

您需要实际的网络文件夹路径。

You need the actual network folder path.

这将工作:

File.Copy(myOriginalFile, "\\myServer\myFolder1\myFolder2\myFile.txt");

更多推荐

将文件复制到共享文件夹的另一台计算机上

本文发布于:2023-11-09 13:50:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机上   另一台   共享文件夹   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!