操作系统 -环境搭建 -粘贴复制 + 共享文件夹

1. Linux虚拟机和Windows实体机实现相互粘贴复制
 

(1)点击虚拟机安装VMware Tools

         然后点击的右边任务栏DVD图标,可以找到VMware Tools压缩文件

(2)把这个VMware Tools压缩文件复制到opt文件夹

        /opt 这个是给第三方协力软体放置的目录 。 什么是第三方协力软体啊?举例来说,KDE这个桌面管理系统是一个独立的计画,不过他可以安装到Linux系统中,因此KDE的软体就建议放置到此目录下了。 另外,如果妳想要自行安装额外的软体(非原本的distribution提供的),那么也能够将你的软体安装到这里来。 不过,以前的Linux系统中,我们还是习惯放置在/usr/local目录下。

复制好时粘贴到opt文件夹时要注意的是,你的权限可能不够而无法进行粘贴,这是root用户登录(sudo passwd 设置root密码)

 

(3)把你所需要的其他目录中的文件进行复制,并且粘贴到当前的这个目录中。或者:也可以在当前目录窗口中删掉不想要的文件


(4)解压VMwaretools安装包

先换为root用户:使用sudo su

进入opt文件夹

解压安装包,安装包为 tar.gz 使用命令:tar -xvzf,格式: tar -xzvf  file.tar.gz  //解压tar.gz

(5)安装VMwaretools

先进入到我们解压出的文件夹中

使用ls命令查看解压出的VMware-tools-distrib文件夹下有哪些文件,可以看到有一个vmware-install.pl文件,执行它就行了

然后回车 ./vmware-install.pl

 然后一路回车 默认安装(注意期间如果遇到询问的且后面跟 [no] 的先不要回车,先输入y然后在回车)

安装完成

(6)然后重启虚拟机使VMwareTools生效

end

2. Linux虚拟机和Windows宿主机设置共享文件夹


(1)我先在D盘下设置一个共享文件夹myshare,在该文件夹下新建一个TXT文件,内容为Hello! linux

(2)进入虚拟机开始设置共享文件夹,点击虚拟机,选择设置

        然后会弹出虚拟机设置的窗口,点击选项,选择共享文件夹,选中总是启用 

 

(3)选择添加,开始添加共享文件夹 

         在弹出的菜单中选择下一步 

        接下来会弹出添加共享文件夹路径的窗口,我们只需将我们设置的共享文件夹路径添加进去就行了 

       我的路径是在D盘的myshare,点击确定 

 

下一步 

选中启动此共享,然后点击完成 

最后一步点击确定,共享文件夹就设置完成了 

我们在计算机mnt文件夹下的hgfs文件夹中可以找到我们设置的共享文件夹

end

参考:https://blog.csdn.net/love20165104027/article/details/83377758

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用C#的System.IO和System.Net命名空间来实现复制本地文件夹共享文件夹的功能。以下是实现的基本步骤: 1. 使用Directory.GetFiles和Directory.GetDirectories方法获取本地文件夹的文件和子文件夹。 2. 使用File.Copy方法将文件从本地文件夹复制共享文件夹。 3. 使用Directory.CreateDirectory方法在共享文件夹创建子文件夹。 4. 递归调用自己,将子文件夹的文件和文件夹复制共享文件夹。 以下是一个示例代码,可以将本地文件夹D:\LocalFolder复制共享文件夹\\Server\SharedFolder: ```csharp using System.IO; using System.Net; public void CopyFolderToSharedFolder() { string localFolderPath = @"D:\LocalFolder"; string sharedFolderPath = @"\\Server\SharedFolder"; // Create a WebRequest instance for the shared folder WebRequest sharedFolderRequest = WebRequest.Create(sharedFolderPath); NetworkCredential credentials = new NetworkCredential("username", "password"); sharedFolderRequest.Credentials = credentials; // Get the response from the shared folder request WebResponse sharedFolderResponse = sharedFolderRequest.GetResponse(); // Get the shared folder stream and create a StreamWriter instance Stream sharedFolderStream = sharedFolderResponse.GetResponseStream(); StreamWriter sharedFolderWriter = new StreamWriter(sharedFolderStream); // Get the files and directories in the local folder string[] files = Directory.GetFiles(localFolderPath); string[] directories = Directory.GetDirectories(localFolderPath); // Copy the files to the shared folder foreach (string file in files) { // Get the filename from the file path string filename = Path.GetFileName(file); // Create the shared file path string sharedFilePath = Path.Combine(sharedFolderPath, filename); // Copy the file to the shared folder File.Copy(file, sharedFilePath); } // Copy the directories to the shared folder foreach (string directory in directories) { // Get the directory name from the directory path string directoryName = Path.GetFileName(directory); // Create the shared directory path string sharedDirectoryPath = Path.Combine(sharedFolderPath, directoryName); // Create the shared directory Directory.CreateDirectory(sharedDirectoryPath); // Recursively copy the files and directories in the local directory to the shared directory CopyFolder(directory, sharedDirectoryPath); } // Close the shared folder stream and response sharedFolderWriter.Close(); sharedFolderResponse.Close(); } private void CopyFolder(string sourceFolderPath, string targetFolderPath) { // Get the files and directories in the source folder string[] files = Directory.GetFiles(sourceFolderPath); string[] directories = Directory.GetDirectories(sourceFolderPath); // Copy the files to the target folder foreach (string file in files) { // Get the filename from the file path string filename = Path.GetFileName(file); // Create the target file path string targetFilePath = Path.Combine(targetFolderPath, filename); // Copy the file to the target folder File.Copy(file, targetFilePath); } // Copy the directories to the target folder foreach (string directory in directories) { // Get the directory name from the directory path string directoryName = Path.GetFileName(directory); // Create the target directory path string targetDirectoryPath = Path.Combine(targetFolderPath, directoryName); // Create the target directory Directory.CreateDirectory(targetDirectoryPath); // Recursively copy the files and directories in the source directory to the target directory CopyFolder(directory, targetDirectoryPath); } } ``` 在上面的代码,我们首先使用WebRequest和NetworkCredential类设置访问共享文件夹所需的凭据。然后,我们使用Directory.GetFiles和Directory.GetDirectories方法获取本地文件夹的文件和子文件夹,并使用File.Copy方法将文件从本地文件夹复制共享文件夹。接下来,我们使用Directory.CreateDirectory方法在共享文件夹创建子文件夹,并递归调用自己,将子文件夹的文件和文件夹复制共享文件夹。最后,我们关闭共享文件夹流和响应。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值