如何在单声道中将文件从 windows 复制到 mac?

How to copy files from windows to mac in mono?

正如标题所说,我想以单声道方式将文件从 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 中找到容器文件夹
  • 打开一个新终端window
    • 键入 cd{space}
  • 将文件夹从 Finder 拖到终端
  • {return}
  • 类型pwd{return }

这会将当前工作目录更改为您导入 finder 的目录,然后 pwd 会将工作目录打印出来(在屏幕上),以便您可以看到路径应该是什么样子。