正如标题所说,我想以单声道将文件从 Windows 复制到 Mac。这是我的 C# 代码:
using System;
using System.IO;
namespace CopyFiles
{
public class EmptyClass
{
public static void Main()
{
string windowsPath = "\\\\another-machine-name\\Share\\Tem";
string macPath = "..";
CopyFiles (windowsPath, macPath);
}
public static bool CopyFiles(string oldPath, string newPath)
{
Directory.CreateDirectory (newPath);
if (!Directory.Exists (oldPath)) {
return false;
}
string[] directories = Directory.GetDirectories (oldPath);
if (directories.Length > 0) {
foreach (string d in directories) {
CopyFiles (d, newPath + d.Substring (d.LastIndexOf ("\\")));
}
}
string[] files = Directory.GetFiles (oldPath);
if (files.Length > 0) {
foreach (string s in files) {
File.Copy (s, newPath + s.Substring (s.LastIndexOf ("\\")));
}
}
return true;
}
}
}
winowsPath
是共享路径。我不知道怎么写mac路径。
有没有人可以帮助我?
最佳答案
我假设代码将在 OS X 端运行。
OS X 的文件系统 /
有一个根节点。其他所有内容都在该根节点下。例如,您的主文件夹中的 document.doc
将被引用为 /Users/Long/document.doc
。
如果您不确定文件的位置,则可以按照以下步骤查找:
- 在 Finder 中找到容器文件夹
- 打开一个新的终端窗口
- 输入cd{空格}
- 将文件夹从 Finder 拖到终端
- 按{return}
- 输入pwd{return}
这会将当前工作目录更改为您放入 finder 的目录,然后 pwd 会将工作目录打印出来(在屏幕上),以便您可以看到路径应该是什么样子。
关于c# - 如何将文件从 windows 复制到单声道的 mac?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31552760/