微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

C#中的文件复制问题不支持给定路径的格式

如何解决C#中的文件复制问题不支持给定路径的格式

这是我的代码,用于将文件一个本地位置复制到另一个本地位置,然后使用Windows Media Player在Winforms中播放它。

我遇到异常“不支持给定路径的格式。”在文件复制期间。

我似乎无法理解这个问题。谁能帮忙吗?预先感谢。

Value of exepath variable- "file:\C:\Users\HP\source\repos\TestProject\TestProject\bin\Debug"

Value of vdopath variable- "file:\C:\Users\HP\source\repos\TestProject\TestProject\bin\Debug\Folder1\Folder2\file"

Value of strtupPath- "C:\Users\HP\source\repos\TestProject\TestProject\bin"

Value of newvdopath- "C:\Users\HP\source\repos\TestProject\TestProject\bin\vdofile.mkv"
   using System.Collections.Generic;
   using System.ComponentModel;
   using System.Data;
   using System.Drawing;
   using System.Linq;
   using System.Text;
   using System.Threading.Tasks;
   using System.Windows.Forms;
   using WMPLib;
   using System.IO;

   namespace TestProject
   {
       public partial class vdo_form_tmplt1 : Form
       {
           public vdo_form_tmplt1()
           {
              InitializeComponent();
           }

           private void PlayVideo_Click(object sender,EventArgs e)
           {
            
               string exepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

               string vdopath = System.IO.Path.Combine(exepath,"Folder1\\Folder2\\file");

               string strtupPath = System.IO.Path.GetDirectoryName(Application.StartupPath);

               string newvdopath = System.IO.Path.Combine(strtupPath,"vdofile.mkv");

               System.IO.File.copy(vdopath,newvdopath);

               axWindowsMediaPlayer1.stretchToFit = true;
               axWindowsMediaPlayer1.URL = newvdopath;
           }

       }
   }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。