呵呵 cnblogs建博第一天分享一下自己的心得 

        [DllImport("Kernel32.dll")]
        public static extern bool DefineDosDevice(int dwFlags, string lpDeviceName, string lpTargetPath);


        /// <summary>
        /// 加载虚拟磁盘
        /// </summary>
        /// <param name="strDeviceName">盘符</param>
        /// <param name="strTargetPath">映射的文件夹</param>
        /// <returns></returns>
        public static bool MapDevice(string strDeviceName, string strTargetPath)
        {
            return DefineDosDevice(0, strDeviceName, strTargetPath);
        }

        /// <summary>
        /// 卸载虚拟磁盘
        /// </summary>
        /// <param name="strDeviceName">盘符</param>
        /// <returns></returns>
        public static bool UnMapDevice(string strDeviceName)
        {
            return DefineDosDevice(3, strDeviceName, "");
        }


        private void button1_Click(object sender, EventArgs e)
        {
            MapDevice("B:",@"C:\Documents and Settings");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            UnMapDevice("B:");
        }
【探索发现】.NET 创建虚拟磁盘

【探索发现】.NET 创建虚拟磁盘

【探索发现】.NET 创建虚拟磁盘

补上源码:

https://files.cnblogs.com/--Sam--/VirtualDevice.rar

相关文章:

  • 2022-01-07
  • 2021-10-17
  • 2022-01-01
  • 2021-04-28
  • 2022-12-23
  • 2021-08-20
  • 2021-04-22
  • 2021-11-13
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2021-10-23
  • 2021-10-27
  • 2021-06-20
  • 2022-12-23
  • 2021-08-15
相关资源
相似解决方案